Skip to content

Commit 60af7ca

Browse files
leorochaelmart-e
authored andcommitted
[IMP] replace simplejson with stdlib json
The stdlib version of the json library is more recent than the 3.5.3 version we are pinning in `requirements.txt` There is no reason to use it. Closes odoo#6940
1 parent 06b3026 commit 60af7ca

File tree

38 files changed

+75
-111
lines changed

38 files changed

+75
-111
lines changed

addons/auth_oauth/controllers/main.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import functools
22
import logging
33

4-
import simplejson
4+
import json
55
import urlparse
66
import werkzeug.utils
77
from werkzeug.exceptions import BadRequest
@@ -62,7 +62,7 @@ def list_providers(self):
6262
client_id=provider['client_id'],
6363
redirect_uri=return_url,
6464
scope=provider['scope'],
65-
state=simplejson.dumps(state),
65+
state=json.dumps(state),
6666
)
6767
provider['auth_link'] = provider['auth_endpoint'] + '?' + werkzeug.url_encode(params)
6868

@@ -132,7 +132,7 @@ class OAuthController(http.Controller):
132132
@http.route('/auth_oauth/signin', type='http', auth='none')
133133
@fragment_to_query_string
134134
def signin(self, **kw):
135-
state = simplejson.loads(kw['state'])
135+
state = json.loads(kw['state'])
136136
dbname = state['d']
137137
provider = state['p']
138138
context = state.get('c', {})
@@ -195,5 +195,5 @@ def oea(self, **kw):
195195
'c': {'no_user_creation': True},
196196
}
197197

198-
kw['state'] = simplejson.dumps(state)
198+
kw['state'] = json.dumps(state)
199199
return self.signin(**kw)

addons/auth_oauth/res_users.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import werkzeug.urls
44
import urlparse
55
import urllib2
6-
import simplejson
6+
import json
77

88
import openerp
99
from openerp.addons.auth_signup.res_users import SignupError
@@ -33,7 +33,7 @@ def _auth_oauth_rpc(self, cr, uid, endpoint, access_token, context=None):
3333
url = endpoint + '?' + params
3434
f = urllib2.urlopen(url)
3535
response = f.read()
36-
return simplejson.loads(response)
36+
return json.loads(response)
3737

3838
def _auth_oauth_validate(self, cr, uid, provider, access_token, context=None):
3939
""" return the validation data corresponding to the access token """
@@ -82,7 +82,7 @@ def _auth_oauth_signin(self, cr, uid, provider, validation, params, context=None
8282
except openerp.exceptions.AccessDenied, access_denied_exception:
8383
if context and context.get('no_user_creation'):
8484
return None
85-
state = simplejson.loads(params['state'])
85+
state = json.loads(params['state'])
8686
token = state.get('t')
8787
values = self._generate_signup_values(cr, uid, provider, validation, params, context=context)
8888
try:

addons/base_geolocalize/models/res_partner.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# Part of Odoo. See LICENSE file for full copyright and licensing details.
33

4-
try:
5-
import simplejson as json
6-
except ImportError:
7-
import json # noqa
4+
import json
85
import urllib
96

107
from openerp.osv import osv, fields

addons/base_import/controllers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
import simplejson
2+
import json
33

44
from openerp.http import Controller, route
55

@@ -15,4 +15,4 @@ def set_file(self, req, file, import_id, jsonp='callback'):
1515
}, req.context)
1616

1717
return 'window.top.%s(%s)' % (
18-
jsonp, simplejson.dumps({'result': written}))
18+
jsonp, json.dumps({'result': written}))

addons/base_setup/base_setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# Part of Odoo. See LICENSE file for full copyright and licensing details.
33

4-
import simplejson
4+
import json
55
import cgi
66
from openerp import tools
77
from openerp.osv import fields, osv

addons/bus/models/bus.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import logging
55
import random
66
import select
7-
import simplejson
87
import threading
98
import time
109

@@ -21,7 +20,7 @@
2120
# Bus
2221
#----------------------------------------------------------
2322
def json_dump(v):
24-
return simplejson.dumps(v, separators=(',', ':'))
23+
return json.dumps(v, separators=(',', ':'))
2524

2625
def hashable(key):
2726
if isinstance(key, list):
@@ -79,8 +78,8 @@ def poll(self, channels, last=0):
7978
for notif in notifications:
8079
result.append({
8180
'id': notif['id'],
82-
'channel': simplejson.loads(notif['channel']),
83-
'message': simplejson.loads(notif['message']),
81+
'channel': json.loads(notif['channel']),
82+
'message': json.loads(notif['message']),
8483
})
8584
return result
8685

addons/calendar/controllers/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import simplejson
1+
import json
22
import openerp
33
import openerp.http as http
44
from openerp.http import request

addons/google_account/controllers/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import simplejson
1+
import json
22
import urllib
33
import openerp
44
from openerp import http
@@ -14,7 +14,7 @@ class google_auth(http.Controller):
1414
def oauth2callback(self, **kw):
1515
""" This route/function is called by Google when user Accept/Refuse the consent of Google """
1616

17-
state = simplejson.loads(kw['state'])
17+
state = json.loads(kw['state'])
1818
dbname = state.get('d')
1919
service = state.get('s')
2020
url_return = state.get('f')

addons/google_account/google_account.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import werkzeug.urls
1212
import urllib2
13-
import simplejson
13+
import json
1414

1515
import logging
1616
_logger = logging.getLogger(__name__)
@@ -37,7 +37,7 @@ def generate_refresh_token(self, cr, uid, service, authorization_code, context=N
3737
error_msg = "Something went wrong during your token generation. Maybe your Authorization Code is invalid or already expired"
3838
raise self.pool.get('res.config.settings').get_config_warning(cr, _(error_msg), context=context)
3939

40-
content = simplejson.loads(content)
40+
content = json.loads(content)
4141
return content.get('refresh_token')
4242

4343
def _get_google_token_uri(self, cr, uid, service, scope, context=None):
@@ -63,7 +63,7 @@ def _get_authorize_uri(self, cr, uid, from_url, service, scope=False, context=No
6363
params = {
6464
'response_type': 'code',
6565
'client_id': client_id,
66-
'state': simplejson.dumps(state_obj),
66+
'state': json.dumps(state_obj),
6767
'scope': scope or 'https://www.googleapis.com/auth/%s' % (service,),
6868
'redirect_uri': base_url + '/google_account/authentication',
6969
'approval_prompt': 'force',
@@ -123,7 +123,7 @@ def _refresh_google_token_json(self, cr, uid, refresh_token, service, context=No
123123
registry = openerp.modules.registry.RegistryManager.get(request.session.db)
124124
with registry.cursor() as cur:
125125
self.pool['res.users'].write(cur, uid, [uid], {'google_%s_rtoken' % service: False}, context=context)
126-
error_key = simplejson.loads(e.read()).get("error", "nc")
126+
error_key = json.loads(e.read()).get("error", "nc")
127127
_logger.exception("Bad google request : %s !" % error_key)
128128
error_msg = "Something went wrong during your token generation. Maybe your Authorization Code is invalid or already expired [%s]" % error_key
129129
raise self.pool.get('res.config.settings').get_config_warning(cr, _(error_msg), context=context)
@@ -156,7 +156,7 @@ def _do_request(self, cr, uid, uri, params={}, headers={}, type='POST', preuri="
156156
response = False
157157
else:
158158
content = request.read()
159-
response = simplejson.loads(content)
159+
response = json.loads(content)
160160

161161
try:
162162
ask_time = datetime.strptime(request.headers.get('date'), "%a, %d %b %Y %H:%M:%S %Z")

addons/google_calendar/google_calendar.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
import operator
4-
import simplejson
4+
import json
55
import urllib2
66

77
import openerp
@@ -267,7 +267,7 @@ def create_an_event(self, cr, uid, event, context=None):
267267

268268
url = "/calendar/v3/calendars/%s/events?fields=%s&access_token=%s" % ('primary', urllib2.quote('id,updated'), self.get_token(cr, uid, context))
269269
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
270-
data_json = simplejson.dumps(data)
270+
data_json = json.dumps(data)
271271

272272
return gs_pool._do_request(cr, uid, url, data_json, headers, type='POST', context=context)
273273

@@ -368,7 +368,7 @@ def update_to_google(self, cr, uid, oe_event, google_event, context):
368368
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
369369
data = self.generate_data(cr, uid, oe_event, context=context)
370370
data['sequence'] = google_event.get('sequence', 0)
371-
data_json = simplejson.dumps(data)
371+
data_json = json.dumps(data)
372372

373373
status, content, ask_time = self.pool['google.service']._do_request(cr, uid, url, data_json, headers, type='PATCH', context=context)
374374

@@ -402,7 +402,7 @@ def update_recurrent_event_exclu(self, cr, uid, instance_id, event_ori_google_id
402402

403403
data['sequence'] = self.get_sequence(cr, uid, instance_id, context)
404404

405-
data_json = simplejson.dumps(data)
405+
data_json = json.dumps(data)
406406
return gs_pool._do_request(cr, uid, url, data_json, headers, type='PUT', context=context)
407407

408408
def update_from_google(self, cr, uid, event, single_event_dict, type, context):
@@ -697,7 +697,7 @@ def update_events(self, cr, uid, lastSync=False, context=None):
697697
registry = openerp.modules.registry.RegistryManager.get(request.session.db)
698698
with registry.cursor() as cur:
699699
self.pool['res.users'].write(cur, SUPERUSER_ID, [uid], {'google_calendar_last_sync_date': False}, context=context)
700-
error_key = simplejson.loads(str(e))
700+
error_key = json.loads(str(e))
701701
error_key = error_key.get('error', {}).get('message', 'nc')
702702
error_msg = "Google is lost... the next synchro will be a full synchro. \n\n %s" % error_key
703703
raise self.pool.get('res.config.settings').get_config_warning(cr, _(error_msg), context=context)
@@ -858,7 +858,7 @@ def update_events(self, cr, uid, lastSync=False, context=None):
858858
try:
859859
self.delete_an_event(cr, uid, current_event[0], context=context)
860860
except Exception, e:
861-
error = simplejson.loads(e.read())
861+
error = json.loads(e.read())
862862
error_nr = error.get('error', {}).get('code')
863863
# if already deleted from gmail or never created
864864
if error_nr in (404, 410,):

addons/google_spreadsheet/google_spreadsheet.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Part of Odoo. See LICENSE file for full copyright and licensing details.
22

33
import cgi
4-
import simplejson
4+
import json
55
import logging
66
from lxml import etree
77
import re
@@ -28,7 +28,7 @@ def write_config_formula(self, cr, uid, attachment_id, spreadsheet_key, model, d
2828
display_fields = []
2929
for node in doc.xpath("//field"):
3030
if node.get('modifiers'):
31-
modifiers = simplejson.loads(node.get('modifiers'))
31+
modifiers = json.loads(node.get('modifiers'))
3232
if not modifiers.get('invisible') and not modifiers.get('tree_invisible'):
3333
display_fields.append(node.get('name'))
3434
fields = " ".join(display_fields)

addons/hw_escpos/controllers/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import commands
33
import logging
4-
import simplejson
4+
import json
55
import os
66
import os.path
77
import io

addons/hw_proxy/controllers/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# -*- coding: utf-8 -*-
22
import logging
33
import commands
4-
import simplejson
4+
import json
55
import os
66
import os.path
77
import openerp
88
import time
99
import random
1010
import subprocess
11-
import simplejson
11+
import json
1212
import werkzeug
1313
import werkzeug.wrappers
1414
_logger = logging.getLogger(__name__)

addons/mail/models/mail_thread.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
import datetime
55
import dateutil
66
import email
7-
try:
8-
import simplejson as json
9-
except ImportError:
10-
import json
7+
import json
118
from lxml import etree
129
import logging
1310
import pytz

addons/payment_adyen/controllers/main.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
try:
4-
import simplejson as json
5-
except ImportError:
6-
import json
3+
import json
74
import logging
85
import pprint
96
import werkzeug

addons/payment_adyen/models/adyen.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# -*- coding: utf-'8' "-*-"
22

33
import base64
4-
try:
5-
import simplejson as json
6-
except ImportError:
7-
import json
4+
import json
85
from hashlib import sha1
96
import hmac
107
import logging

addons/payment_buckaroo/controllers/main.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
try:
3-
import simplejson as json
4-
except ImportError:
5-
import json
6-
2+
import json
73
import logging
84
import pprint
95
import werkzeug

addons/payment_paypal/controllers/main.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
try:
4-
import simplejson as json
5-
except ImportError:
6-
import json
3+
import json
74
import logging
85
import pprint
96
import urllib2

addons/payment_paypal/models/paypal.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# -*- coding: utf-'8' "-*-"
22

33
import base64
4-
try:
5-
import simplejson as json
6-
except ImportError:
7-
import json
4+
import json
85
import logging
96
import urlparse
107
import werkzeug.urls

addons/payment_sips/controllers/main.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
try:
4-
import simplejson as json
5-
except ImportError:
6-
import json
3+
import json
74
import logging
85
import werkzeug
96

addons/payment_sips/models/sips.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# -*- coding: utf-'8' "-*-"
22

3-
try:
4-
import simplejson as json
5-
except ImportError:
6-
import json
3+
import json
74
import logging
85
from hashlib import sha256
96
import urlparse

addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init_posbox_image.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ apt-get -y autoremove
3131
apt-get update
3232
apt-get -y dist-upgrade
3333

34-
PKGS_TO_INSTALL="adduser postgresql-client python python-dateutil python-decorator python-docutils python-feedparser python-imaging python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-passlib python-psutil python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing python-pypdf python-reportlab python-requests python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-werkzeug python-xlwt python-yaml postgresql python-gevent python-serial python-pip python-dev localepurge vim mc mg screen"
34+
PKGS_TO_INSTALL="adduser postgresql-client python python-dateutil python-decorator python-docutils python-feedparser python-imaging python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-passlib python-psutil python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing python-pypdf python-reportlab python-requests python-tz python-vatnumber python-vobject python-werkzeug python-xlwt python-yaml postgresql python-gevent python-serial python-pip python-dev localepurge vim mc mg screen"
3535

3636
apt-get -y install ${PKGS_TO_INSTALL}
3737

0 commit comments

Comments
 (0)