http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11540
Revision: 11540 Author: drtrigon Date: 2013-05-17 17:23:42 +0000 (Fri, 17 May 2013) Log Message: ----------- improvement; preparing move of svn:externals to externals/ dir
Modified Paths: -------------- trunk/pywikipedia/commonsdelinker/checkusage.py trunk/pywikipedia/commonsdelinker/image_replacer.py trunk/pywikipedia/externals/__init__.py trunk/pywikipedia/generate_family_file.py trunk/pywikipedia/panoramiopicker.py trunk/pywikipedia/query.py trunk/pywikipedia/tests/test_externals.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/commonsdelinker/checkusage.py =================================================================== --- trunk/pywikipedia/commonsdelinker/checkusage.py 2013-05-16 08:16:52 UTC (rev 11539) +++ trunk/pywikipedia/commonsdelinker/checkusage.py 2013-05-17 17:23:42 UTC (rev 11540) @@ -40,10 +40,11 @@
import httplib, urlparse, socket, time from urllib import urlencode -import simplejson
import wikipedia, family
+import simplejson # after 'wikipedia' because of externals path + try: import MySQLdb except ImportError:
Modified: trunk/pywikipedia/commonsdelinker/image_replacer.py =================================================================== --- trunk/pywikipedia/commonsdelinker/image_replacer.py 2013-05-16 08:16:52 UTC (rev 11539) +++ trunk/pywikipedia/commonsdelinker/image_replacer.py 2013-05-17 17:23:42 UTC (rev 11540) @@ -10,7 +10,8 @@ # Distributed under the terms of the MIT license. # __version__ = '$Id$' -import config, wikipedia, simplejson +import config, wikipedia +import simplejson # after 'wikipedia' because of externals path import re, time import sys, os, signal, traceback
Modified: trunk/pywikipedia/externals/__init__.py =================================================================== --- trunk/pywikipedia/externals/__init__.py 2013-05-16 08:16:52 UTC (rev 11539) +++ trunk/pywikipedia/externals/__init__.py 2013-05-17 17:23:42 UTC (rev 11540) @@ -41,7 +41,7 @@ # TODO: vvv # 'simplejson' has to be moved and integrated (in)to externals as well # 'spelling' has to be moved and integrated (in)to externals as well -# 'i18n' has to be moved and integrated (in)to externals as well +# 'BeautifulSoup.py' has to be moved and integrated (in)to externals as well # $ svn propget svn:externals pywikipedia/ # spelling http://svn.wikimedia.org/svnroot/pywikipedia/trunk/spelling/ # simplejson http://simplejson.googlecode.com/svn/tags/simplejson-2.1.3/simplejson/ @@ -131,13 +131,10 @@
import os, sys
-import wikipedia as pywikibot +import wikipedia as pywikibot # sets externals path from pywikibot.comms import http
-sys.path.append(os.path.dirname(os.path.abspath(os.path.join(os.curdir, __file__)))) - - ### BEGIN of VisTrails inspired and copied code ### ### ### ### ### ### ### ###
def guess_system():
Modified: trunk/pywikipedia/generate_family_file.py =================================================================== --- trunk/pywikipedia/generate_family_file.py 2013-05-16 08:16:52 UTC (rev 11539) +++ trunk/pywikipedia/generate_family_file.py 2013-05-17 17:23:42 UTC (rev 11540) @@ -31,11 +31,6 @@ # parsing response data from BeautifulSoup import BeautifulSoup
-try: - import json -except ImportError: - import simplejson as json - # Monkey-patching wikipediatools to prevent questions about user_config.py import wikipediatools wikipediatools.get_base_dir = lambda: '.' @@ -48,6 +43,11 @@ import wikipedia import family
+try: + import json +except ImportError: + import simplejson as json # after 'wikipedia' because of externals path + class FamilyFileGenerator(object): def __init__(self, url=None, name=None, dointerwiki=None): if url == None:
Modified: trunk/pywikipedia/panoramiopicker.py =================================================================== --- trunk/pywikipedia/panoramiopicker.py 2013-05-16 08:16:52 UTC (rev 11539) +++ trunk/pywikipedia/panoramiopicker.py 2013-05-17 17:23:42 UTC (rev 11540) @@ -12,6 +12,10 @@ __version__ = '$Id$'
import sys, urllib, re, StringIO, hashlib, base64, time + +import wikipedia as pywikibot +import config, query, imagerecat, upload + try: #For Python 2.6 newer import json @@ -20,9 +24,7 @@ # http://pypi.python.org/pypi/python-json raise ImportError except ImportError: - import simplejson as json -import wikipedia as pywikibot -import config, query, imagerecat, upload + import simplejson as json # after 'wikipedia' because of externals path
from Tkinter import * from PIL import Image, ImageTk # see: http://www.pythonware.com/products/pil/
Modified: trunk/pywikipedia/query.py =================================================================== --- trunk/pywikipedia/query.py 2013-05-16 08:16:52 UTC (rev 11539) +++ trunk/pywikipedia/query.py 2013-05-17 17:23:42 UTC (rev 11540) @@ -37,7 +37,7 @@ # http://pypi.python.org/pypi/python-json raise ImportError except ImportError: - import simplejson as json + import simplejson as json # after 'wikipedia' because of externals path
@deprecate_arg("encodeTitle", None) def GetData(params, site=None, useAPI=True, retryCount=config.maxretries,
Modified: trunk/pywikipedia/tests/test_externals.py =================================================================== --- trunk/pywikipedia/tests/test_externals.py 2013-05-16 08:16:52 UTC (rev 11539) +++ trunk/pywikipedia/tests/test_externals.py 2013-05-17 17:23:42 UTC (rev 11540) @@ -13,7 +13,7 @@ __version__ = '$Id$'
import unittest -import test_pywiki +import test_pywiki # imports 'wikipedia' and sets externals path
import sys, os
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2013-05-16 08:16:52 UTC (rev 11539) +++ trunk/pywikipedia/wikipedia.py 2013-05-17 17:23:42 UTC (rev 11540) @@ -133,6 +133,8 @@ __version__ = '$Id$'
import os, sys +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), + 'externals')) # allow imports from externals import httplib, socket, urllib, urllib2, cookielib import traceback, pprint import time, threading, Queue