http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9914
Revision: 9914 Author: binbot Date: 2012-02-20 09:32:00 +0000 (Mon, 20 Feb 2012) Log Message: ----------- Enable calling main() of arbitrary module from within another script. Solution proposed by Merlijn, http://thread.gmane.org/gmane.comp.python.pywikipediabot.general/12420/focus...
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2012-02-20 08:52:32 UTC (rev 9913) +++ trunk/pywikipedia/wikipedia.py 2012-02-20 09:32:00 UTC (rev 9914) @@ -7688,6 +7688,10 @@ return os.path.basename(called)
def _decodeArg(arg): + # We may pass a Unicode string to a script upon importing and calling + # main() from another script. + if isinstance(arg,unicode): + return arg if sys.platform == 'win32': if config.console_encoding in ('cp437', 'cp850'): # Western Windows versions give parameters encoded as windows-1252