Revision: 6415 Author: russblau Date: 2009-02-22 20:15:45 +0000 (Sun, 22 Feb 2009)
Log Message: ----------- fix one of a zillion Windows quirks
Modified Paths: -------------- branches/rewrite/pywikibot/bot.py branches/rewrite/pywikibot/pagegenerators.py
Modified: branches/rewrite/pywikibot/bot.py =================================================================== --- branches/rewrite/pywikibot/bot.py 2009-02-22 18:12:08 UTC (rev 6414) +++ branches/rewrite/pywikibot/bot.py 2009-02-22 20:15:45 UTC (rev 6415) @@ -291,9 +291,9 @@
def _decodeArg(arg): if sys.platform=='win32': - if config.console_encoding == 'cp850': + if config.console_encoding in ("cp437", 'cp850'): # Western Windows versions give parameters encoded as windows-1252 - # even though the console encoding is cp850. + # even though the console encoding is cp850 or cp437. return unicode(arg, 'windows-1252') elif config.console_encoding == 'cp852': # Central/Eastern European Windows versions give parameters encoded
Modified: branches/rewrite/pywikibot/pagegenerators.py =================================================================== --- branches/rewrite/pywikibot/pagegenerators.py 2009-02-22 18:12:08 UTC (rev 6414) +++ branches/rewrite/pywikibot/pagegenerators.py 2009-02-22 20:15:45 UTC (rev 6415) @@ -605,10 +605,10 @@
def DuplicateFilterPageGenerator(generator): """Yield all unique pages from another generator, omitting duplicates.""" - seenPages = {} + seenPages = set([]) for page in generator: if page not in seenPages: - seenPages[page] = None + seenPages.add(page) yield page
@@ -946,11 +946,11 @@ yield pywikibot.Page(pywikibot.Link(fd(month, day), site))
-if __name__ == "__main__": +def main(*args): try: gen = None genFactory = GeneratorFactory() - for arg in pywikibot.handleArgs(): + for arg in pywikibot.handleArgs(*args): genFactory.handleArg(arg) gen = genFactory.getCombinedGenerator() if gen: @@ -958,5 +958,11 @@ pywikibot.output(page.title(), toStdout = True) else: pywikibot.showHelp() + except Exception: + pywikibot.logging.exception("") finally: pywikibot.stopme() + + +if __name__=="__main__": + main()