44
55Author: Florent Xicluna
66"""
7+ import _ast
78import atexit
89import csv
910import functools
1617import time
1718import traceback
1819
19- import _ast
2020
2121PY2 = sys .version_info [0 ] == 2
2222if not PY2 : # Python 3
2323 from configparser import ConfigParser
2424 from threading import current_thread
2525 from urllib .request import Request , urlopen
26- from xmlrpc .client import Fault , ServerProxy , MININT , MAXINT
26+ from xmlrpc .client import MAXINT , MININT , Fault , ServerProxy
2727else : # Python 2
28- from ConfigParser import SafeConfigParser as ConfigParser
2928 from threading import currentThread as current_thread
29+
30+ from ConfigParser import SafeConfigParser as ConfigParser
3031 from urllib2 import Request , urlopen
31- from xmlrpclib import Fault , ServerProxy , MININT , MAXINT
32+ from xmlrpclib import MAXINT , MININT , Fault , ServerProxy
3233
3334try :
3435 import requests
@@ -166,7 +167,6 @@ def _dict_to_list(self, rowdict):
166167 for cell in rowlst
167168 ]
168169
169-
170170else : # Python 3
171171 basestring = str
172172 int_types = int
@@ -441,7 +441,6 @@ def http_post(url, data, headers={"Content-Type": "application/json"}):
441441 resp = requests .post (url , data = data , headers = headers )
442442 return resp .json ()
443443
444-
445444else :
446445
447446 def http_post (url , data , headers = {"Content-Type" : "application/json" }):
@@ -455,12 +454,12 @@ def dispatch_jsonrpc(url, service_name, method, args):
455454 "jsonrpc" : "2.0" ,
456455 "method" : "call" ,
457456 "params" : {"service" : service_name , "method" : method , "args" : args },
458- "id" : "%04x%010x" % (os .getpid (), (int (time .time () * 1e6 ) % 2 ** 40 )),
457+ "id" : "%04x%010x" % (os .getpid (), (int (time .time () * 1e6 ) % 2 ** 40 )),
459458 }
460459 resp = http_post (url , json .dumps (data ).encode ("ascii" ))
461460 if resp .get ("error" ):
462461 raise ServerError (resp ["error" ])
463- return resp [ "result" ]
462+ return resp . get ( "result" )
464463
465464
466465class partial (functools .partial ):
@@ -544,13 +543,13 @@ def wrapper(self, *args):
544543class Env (object ):
545544 """An environment wraps data for Odoo models and records:
546545
547- - :attr:`db_name`, the current database;
548- - :attr:`uid`, the current user id;
549- - :attr:`context`, the current context dictionary.
546+ - :attr:`db_name`, the current database;
547+ - :attr:`uid`, the current user id;
548+ - :attr:`context`, the current context dictionary.
550549
551- To retrieve an instance of ``some.model``:
550+ To retrieve an instance of ``some.model``:
552551
553- >>> env["some.model"]
552+ >>> env["some.model"]
554553 """
555554
556555 name = uid = user = None
@@ -1953,7 +1952,12 @@ def _set_external_id(self, xml_id):
19531952 if self .env ["ir.model.data" ].search (domain ):
19541953 raise ValueError ("ID %r collides with another entry" % xml_id )
19551954 self .env ["ir.model.data" ].create (
1956- {"model" : self ._name , "res_id" : self .id , "module" : mod , "name" : name ,}
1955+ {
1956+ "model" : self ._name ,
1957+ "res_id" : self .id ,
1958+ "module" : mod ,
1959+ "name" : name ,
1960+ }
19571961 )
19581962
19591963 def __getattr__ (self , attr ):
0 commit comments