Use simplejson first, and centralize import
simplejson is supposed to be faster: http://stackoverflow.com/questions/712791/json-and-simplejson-module-differences-in-python
This commit is contained in:
parent
7c0bcfe499
commit
b8d1a52732
7 changed files with 36 additions and 30 deletions
|
|
@ -24,12 +24,9 @@ import datetime
|
|||
import random
|
||||
import urllib
|
||||
from htmlentitydefs import codepoint2name
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword, BrowserUnavailable
|
||||
from weboob.tools.json import json
|
||||
|
||||
from weboob.capabilities.chat import ChatException, ChatMessage
|
||||
from weboob.capabilities.messages import CantSendMessage
|
||||
|
|
|
|||
|
|
@ -19,14 +19,10 @@
|
|||
|
||||
from __future__ import with_statement
|
||||
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
import re
|
||||
|
||||
from weboob.capabilities.gallery import ICapGallery, BaseGallery, BaseImage
|
||||
from weboob.tools.json import json
|
||||
from weboob.tools.backend import BaseBackend
|
||||
from weboob.tools.browser import BaseBrowser, BasePage
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,9 @@ import urllib
|
|||
import datetime
|
||||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
from weboob.tools.json import json as simplejson
|
||||
from weboob.capabilities.content import Revision
|
||||
|
||||
try:
|
||||
import simplejson
|
||||
except ImportError:
|
||||
# Python 2.6+ has a module similar to simplejson
|
||||
import json as simplejson
|
||||
|
||||
__all__ = ['MediawikiBrowser']
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from weboob.tools.browser import BaseBrowser, BasePage
|
||||
from weboob.tools.json import json
|
||||
from weboob.capabilities.video import BaseVideo
|
||||
from weboob.tools.browser.decorators import id2url
|
||||
|
||||
|
|
@ -25,11 +26,6 @@ from StringIO import StringIO
|
|||
from time import time
|
||||
import re
|
||||
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
try:
|
||||
from urlparse import parse_qs
|
||||
except ImportError:
|
||||
|
|
|
|||
|
|
@ -18,14 +18,10 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
import urllib
|
||||
|
||||
from weboob.tools.browser import BasePage, BrokenPageError, BrowserIncorrectPassword
|
||||
from weboob.tools.json import json
|
||||
|
||||
|
||||
__all__ = ['LoginPage', 'LoginRedirectPage', 'ForbiddenVideo', 'ForbiddenVideoPage', \
|
||||
|
|
|
|||
30
weboob/tools/json.py
Normal file
30
weboob/tools/json.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2012 Laurent Bachelier
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# because we don't want to import this file by "import json"
|
||||
from __future__ import absolute_import
|
||||
|
||||
__all__ = ['json']
|
||||
|
||||
try:
|
||||
# try simplejson first because it is faster
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
# Python 2.6+ has a module similar to simplejson
|
||||
import json
|
||||
|
|
@ -18,11 +18,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
from weboob.tools.json import json
|
||||
from .iparser import IParser
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue