Hello PywikibotCommitWatcher,
I'd like you to do a code review. Please visit
https://gerrit.wikimedia.org/r/76350
to review the following change.
Change subject: improvement; change external simplejson from git submodule to internal management ......................................................................
improvement; change external simplejson from git submodule to internal management
Change-Id: Ic0e2e9ca1c631088674fff7728e9a82df88bcf22 --- M .gitmodules M externals/__init__.py D externals/simplejson 3 files changed, 5 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/compat refs/changes/50/76350/1
diff --git a/.gitmodules b/.gitmodules index 7a21ee4..3ceaddf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,3 @@ [submodule "externals/spelling"] path = externals/spelling url = https://gerrit.wikimedia.org/r/p/pywikibot/spelling.git -[submodule "externals/simplejson"] - path = externals/simplejson - url = https://github.com/simplejson/simplejson.git diff --git a/externals/__init__.py b/externals/__init__.py index 89baed3..e9cd061 100644 --- a/externals/__init__.py +++ b/externals/__init__.py @@ -54,12 +54,11 @@ # 'spelling': $ svn propedit svn:externals externals/. # spelling http://svn.wikimedia.org/svnroot/pywikipedia/trunk/spelling/ # $ git submodule add https://gerrit.wikimedia.org/r/p/pywikibot/spelling.git externals/spelling -# 'simplejson': $ svn propedit svn:externals externals/. -# simplejson http://simplejson.googlecode.com/svn/tags/simplejson-2.1.3/simplejson/ -# $ git submodule add https://github.com/simplejson/simplejson.git externals/simplejson -# $ cd externals/simplejson; git checkout v2.1.3 -# 'simplejson': ({'linux-fedora': ['python-simplejson'], -# 'linux-ubuntu': [''],}, + 'simplejson': ({'linux-fedora': ['python-simplejson'], + 'linux-ubuntu': ['']}, + { 'url': 'https://github.com/simplejson/simplejson/archive/v2.1.3.zip', + 'path': 'simplejson-2.1.3/simplejson'}, + {}), # ?? 'BeautifulSoup.py': ({'linux-fedora': ['python-BeautifulSoup'], 'linux-ubuntu': ['']}, { 'url': 'https://pypi.python.org/packages/source/B/BeautifulSoup/BeautifulSoup-3.2.0....', diff --git a/externals/simplejson b/externals/simplejson deleted file mode 160000 index 04d4032..0000000 --- a/externals/simplejson +++ /dev/null -Subproject commit 04d4032816f7faa64912b487060d2c475f595c46
DrTrigon has posted comments on this change.
Change subject: improvement; change external simplejson from git submodule to internal management ......................................................................
Patch Set 1:
Yes would be the another possibilty - why not?
DrTrigon has posted comments on this change.
Change subject: improvement; change external simplejson from git submodule to internal management ......................................................................
Patch Set 1: Verified+1 Code-Review+1
Xqt has posted comments on this change.
Change subject: improvement; change external simplejson from git submodule to internal management ......................................................................
Patch Set 1: Code-Review-1
We should not longer support py2.5 and older releases. It doesn't work for other parts like i18n PLURAL support etc. See also http://www.mediawiki.org/wiki/Manual:Pywikipediabot/Overview
DrTrigon has posted comments on this change.
Change subject: improvement; change external simplejson from git submodule to internal management ......................................................................
Patch Set 1:
@Ladsgroup: 1) I had no time to include the externals handling into core yet. 2) Regarding compat, a few 2 or 3 submodules are there and can be cloned directly by using '--recursive', the other python modules needed get downloaded on first use by externals/__init__.py - so to answer your question; submodules HAVE TO, the others CAN be included into nightlies, later will be downloaded anyway if not included.
@Merlijn, Xqt: Ok I will change this patch in order to completely remove simplejson (from both submodule and externals/__init__.py). But first I have to make 'git review -d ID' working on my machine, sorry for the delay!
Hello Xqt, jenkins-bot,
I'd like you to reexamine a change. Please visit
https://gerrit.wikimedia.org/r/76350
to look at the new patch set (#2).
Change subject: improvement; remove simplejson from git submodule and externals management ......................................................................
improvement; remove simplejson from git submodule and externals management
Change-Id: Ic0e2e9ca1c631088674fff7728e9a82df88bcf22 --- M .gitmodules M externals/__init__.py D externals/simplejson 3 files changed, 0 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/compat refs/changes/50/76350/2
jenkins-bot has posted comments on this change.
Change subject: improvement; remove simplejson from git submodule and externals management ......................................................................
Patch Set 2: Verified+2
Build succeeded.
- https://integration.wikimedia.org/ci/job/pywikibot-compat-pep8/15/console : FAILURE in 14s (non-voting) - https://integration.wikimedia.org/ci/job/pywikibot-compat-pyflakes/13/consol... : FAILURE in 13s (non-voting)
DrTrigon has posted comments on this change.
Change subject: improvement; remove simplejson from git submodule and externals management ......................................................................
Patch Set 2: Verified+1 Code-Review+1
Legoktm has posted comments on this change.
Change subject: improvement; remove simplejson from git submodule and externals management ......................................................................
Patch Set 2: Code-Review-1
You also need to remove all the instances where it is currently used (via a simple grep):
- generate_family_file.py: import simplejson as json # after 'wikipedia' because of externals path - panoramiopicker.py: import simplejson as json # after 'wikipedia' because of externals path - query.py: import simplejson as json # after 'wikipedia' because of externals path - wikipedia.py: import simplejson as json
DrTrigon has posted comments on this change.
Change subject: improvement; remove simplejson from git submodule and externals management ......................................................................
Patch Set 2:
I'm not sure about this. I just removed simplejson from externals and submodule (as the commit message tells). But you can still install python-simplejson manually on your machine in order to profit from the code.
Shall I convert this change to "improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped)"??
Hello Legoktm, Xqt, jenkins-bot,
I'd like you to reexamine a change. Please visit
https://gerrit.wikimedia.org/r/76350
to look at the new patch set (#3).
Change subject: improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped) ......................................................................
improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped)
Change-Id: Ic0e2e9ca1c631088674fff7728e9a82df88bcf22 --- M .gitmodules M CONTENTS M catimages.py M commonsdelinker/checkusage.py M commonsdelinker/delinker.py M commonsdelinker/image_replacer.py M externals/__init__.py D externals/simplejson M generate_family_file.py M panoramiopicker.py M query.py M tests/test_externals.py M wikipedia.py 13 files changed, 10 insertions(+), 53 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/compat refs/changes/50/76350/3
jenkins-bot has posted comments on this change.
Change subject: improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped) ......................................................................
Patch Set 3: Verified+2
Build succeeded.
- https://integration.wikimedia.org/ci/job/pywikibot-compat-pep8/16/console : FAILURE in 4s (non-voting) - https://integration.wikimedia.org/ci/job/pywikibot-compat-pyflakes/14/consol... : FAILURE in 3s (non-voting)
DrTrigon has posted comments on this change.
Change subject: improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped) ......................................................................
Patch Set 3: Verified+1 Code-Review+1
DrTrigon has posted comments on this change.
Change subject: improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped) ......................................................................
Patch Set 3:
Is this change ok now? Can I approve?
Xqt has posted comments on this change.
Change subject: improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped) ......................................................................
Patch Set 3: Code-Review+2
jenkins-bot has posted comments on this change.
Change subject: improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped) ......................................................................
Patch Set 3: -Verified
Starting gate-and-submit jobs. https://integration.wikimedia.org/zuul/
jenkins-bot has posted comments on this change.
Change subject: improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped) ......................................................................
Patch Set 3: Verified+2
Build succeeded.
- https://integration.wikimedia.org/ci/job/pywikibot-compat-pep8/17/console : FAILURE in 3s (non-voting) - https://integration.wikimedia.org/ci/job/pywikibot-compat-pyflakes/15/consol... : FAILURE in 3s (non-voting)
jenkins-bot has submitted this change and it was merged.
Change subject: improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped) ......................................................................
improvement; remove simplejson support completely, use json instead (py2.5 compatibility droped)
Change-Id: Ic0e2e9ca1c631088674fff7728e9a82df88bcf22 --- M .gitmodules M CONTENTS M catimages.py M commonsdelinker/checkusage.py M commonsdelinker/delinker.py M commonsdelinker/image_replacer.py M externals/__init__.py D externals/simplejson M generate_family_file.py M panoramiopicker.py M query.py M tests/test_externals.py M wikipedia.py 13 files changed, 10 insertions(+), 53 deletions(-)
Approvals: DrTrigon: Checked; Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/.gitmodules b/.gitmodules index 7a21ee4..3ceaddf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,3 @@ [submodule "externals/spelling"] path = externals/spelling url = https://gerrit.wikimedia.org/r/p/pywikibot/spelling.git -[submodule "externals/simplejson"] - path = externals/simplejson - url = https://github.com/simplejson/simplejson.git diff --git a/CONTENTS b/CONTENTS index 8fbb3f9..24abdb1 100644 --- a/CONTENTS +++ b/CONTENTS @@ -259,8 +259,6 @@ externals : Contains all external software that might be used by by PyWikipediaBot scripts and libraries. The most important among them are: - * simplejson; used by query.py and needed for python - release prev. 2.6 * spelling; dictionaries for spellcheck.py * BeautifulSoup.py; http://www.crummy.com/software/BeautifulSoup (and more) diff --git a/catimages.py b/catimages.py index 0ed7684..10b3376 100644 --- a/catimages.py +++ b/catimages.py @@ -48,7 +48,7 @@
# python default packages import re, urllib2, os, locale, sys, datetime, math, shutil, mimetypes, shelve -import StringIO, json # fallback: simplejson +import StringIO, json from subprocess import Popen, PIPE try: import Image # classic 'PIL' diff --git a/commonsdelinker/checkusage.py b/commonsdelinker/checkusage.py index 67bc2fd..9fa32d4 100644 --- a/commonsdelinker/checkusage.py +++ b/commonsdelinker/checkusage.py @@ -43,7 +43,7 @@
import wikipedia, family
-import simplejson # after 'wikipedia' because of externals path +import json
try: import MySQLdb @@ -141,7 +141,7 @@ self._conn.close() self.__init__(self.host) try: - data = simplejson.load(res) + data = json.load(res) finally: res.close()
diff --git a/commonsdelinker/delinker.py b/commonsdelinker/delinker.py index c674071..18d09dd 100644 --- a/commonsdelinker/delinker.py +++ b/commonsdelinker/delinker.py @@ -23,7 +23,7 @@ # Distributed under the terms of the MIT license. # __version__ = '$Id$' -# This script requires MySQLdb and simplejson. Tested with: +# This script requires MySQLdb and json. Tested with: # * Python 2.4.4, MySQLdb 1.2.1_p, simplejson 1.3 # * Python 2.5, MySQLdb 1.2.2, simplejson 1.5 (recommended) # TODO: diff --git a/commonsdelinker/image_replacer.py b/commonsdelinker/image_replacer.py index f5d8015..dec7c08 100644 --- a/commonsdelinker/image_replacer.py +++ b/commonsdelinker/image_replacer.py @@ -11,7 +11,7 @@ # __version__ = '$Id$' import config, wikipedia -import simplejson # after 'wikipedia' because of externals path +import json import re, time import sys, os, signal, traceback
@@ -163,7 +163,7 @@ if since: predata.append(('rvend', since)) response, data = self.site.postForm(address, predata) - data = simplejson.loads(data) + data = json.loads(data) if 'error' in data: raise RuntimeError(data['error'])
diff --git a/externals/__init__.py b/externals/__init__.py index 89baed3..cabe6d1 100644 --- a/externals/__init__.py +++ b/externals/__init__.py @@ -54,12 +54,6 @@ # 'spelling': $ svn propedit svn:externals externals/. # spelling http://svn.wikimedia.org/svnroot/pywikipedia/trunk/spelling/ # $ git submodule add https://gerrit.wikimedia.org/r/p/pywikibot/spelling.git externals/spelling -# 'simplejson': $ svn propedit svn:externals externals/. -# simplejson http://simplejson.googlecode.com/svn/tags/simplejson-2.1.3/simplejson/ -# $ git submodule add https://github.com/simplejson/simplejson.git externals/simplejson -# $ cd externals/simplejson; git checkout v2.1.3 -# 'simplejson': ({'linux-fedora': ['python-simplejson'], -# 'linux-ubuntu': [''],}, 'BeautifulSoup.py': ({'linux-fedora': ['python-BeautifulSoup'], 'linux-ubuntu': ['']}, { 'url': 'https://pypi.python.org/packages/source/B/BeautifulSoup/BeautifulSoup-3.2.0....', diff --git a/externals/simplejson b/externals/simplejson deleted file mode 160000 index 04d4032..0000000 --- a/externals/simplejson +++ /dev/null -Subproject commit 04d4032816f7faa64912b487060d2c475f595c46 diff --git a/generate_family_file.py b/generate_family_file.py index 64286ab..06464c9 100644 --- a/generate_family_file.py +++ b/generate_family_file.py @@ -45,10 +45,7 @@ # parsing response data from BeautifulSoup import BeautifulSoup
-try: - import json -except ImportError: - import simplejson as json # after 'wikipedia' because of externals path +import json
class FamilyFileGenerator(object): def __init__(self, url=None, name=None, dointerwiki=None): diff --git a/panoramiopicker.py b/panoramiopicker.py index d7cb218..33549fd 100644 --- a/panoramiopicker.py +++ b/panoramiopicker.py @@ -18,15 +18,7 @@ import externals # check for and install needed externals.check_setup('BeautifulSoup.py') # 'externals'
-try: - #For Python 2.6 newer - import json - if not hasattr(json, 'loads'): - # 'json' can also be the name in for - # http://pypi.python.org/pypi/python-json - raise ImportError -except ImportError: - import simplejson as json # after 'wikipedia' because of externals path +import json
from Tkinter import * from PIL import Image, ImageTk # see: http://www.pythonware.com/products/pil/ diff --git a/query.py b/query.py index e5414aa..ced5323 100644 --- a/query.py +++ b/query.py @@ -29,15 +29,7 @@ import wikipedia as pywikibot import config from pywikibot.support import deprecate_arg -try: - #For Python 2.6 newer - import json - if not hasattr(json, 'loads'): - # 'json' can also be the name in for - # http://pypi.python.org/pypi/python-json - raise ImportError -except ImportError: - import simplejson as json # after 'wikipedia' because of externals path +import json
@deprecate_arg("encodeTitle", None) def GetData(params, site=None, useAPI=True, retryCount=config.maxretries, diff --git a/tests/test_externals.py b/tests/test_externals.py index cd892d6..8c45a94 100644 --- a/tests/test_externals.py +++ b/tests/test_externals.py @@ -27,10 +27,6 @@
class PyWikiExternalImporterTestCase(test_pywiki.PyWikiTestCase):
- def test_simplejson(self): - import simplejson - self.assertTrue( "simplejson" in sys.modules ) - def test_spelling(self): self.assertTrue(os.path.exists(os.path.join(scriptdir, '../externals/spelling')))
diff --git a/wikipedia.py b/wikipedia.py index eba0e71..e476b3b 100644 --- a/wikipedia.py +++ b/wikipedia.py @@ -151,16 +151,7 @@ from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, SoupStrainer import weakref import logging, logging.handlers -try: - #For Python 2.6 newer - import json - if not hasattr(json, 'loads'): - # 'json' can also be the name in for - # http://pypi.python.org/pypi/python-json - raise ImportError -except ImportError: - externals.check_setup('simplejson') - import simplejson as json +import json # Splitting the bot into library parts from pywikibot.support import * import config, login, query
pywikibot-commits@lists.wikimedia.org