http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10273
Revision: 10273 Author: valhallasw Date: 2012-06-03 08:17:36 +0000 (Sun, 03 Jun 2012) Log Message: ----------- + wrapper script to use rewrite in 'directory' mode - run scripts using python pwb.py <name_of_script> <options>
and it will use the package directory to store all user files, will fix up search paths so the package does not need to be installed, etc.
Added Paths: ----------- branches/rewrite/pwb.py
Added: branches/rewrite/pwb.py =================================================================== --- branches/rewrite/pwb.py (rev 0) +++ branches/rewrite/pwb.py 2012-06-03 08:17:36 UTC (rev 10273) @@ -0,0 +1,24 @@ +import sys,os +sys.path.append('.') +sys.path.append('externals') +sys.path.append('pywikibot/compat') + +if "PYWIKIBOT2_DIR" not in os.environ: + os.environ["PYWIKIBOT2_DIR"] = os.path.split(__file__)[0] + +sys.argv.pop(0) +if len(sys.argv) > 0: + if not os.path.exists(sys.argv[0]): + testpath = os.path.join(os.path.split(__file__)[0], 'scripts', sys.argv[0]) + if os.path.exists(testpath): + sys.argv[0] = testpath + else: + testpath = testpath + '.py' + if os.path.exists(testpath): + sys.argv[0] = testpath + else: + raise Exception("%s not found!" % sys.argv[0]) + sys.path.append(os.path.split(sys.argv[0])[0]) + execfile(sys.argv[0]) +else: + sys.argv.append('')