Xqt has uploaded a new change for review. https://gerrit.wikimedia.org/r/276426
Change subject: [IMPR] Stopme is done at exit time by default ...................................................................... [IMPR] Stopme is done at exit time by default - stopme() is registered to be executed at exit time - remove stopme() from scripts - use main() method as usual Change-Id: Ice68e65510cc29e797830a1b5cdbf957df29bb40 --- M scripts/imageharvest.py M scripts/standardize_interwiki.py 2 files changed, 31 insertions(+), 27 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/26/276426/1 diff --git a/scripts/imageharvest.py b/scripts/imageharvest.py index 6e5e366..3eb6f80 100644 --- a/scripts/imageharvest.py +++ b/scripts/imageharvest.py @@ -16,7 +16,7 @@ -shown Choose images shown on the page as well as linked from it -justshown Choose _only_ images shown on the page, not those linked """ -# (C) Pywikibot team, 2004-2015 +# (C) Pywikibot team, 2004-2016 # # Distributed under the terms of the MIT license. # @@ -127,7 +127,8 @@ break -try: +def main(*args): + """Process command line arguments and invoke bot.""" url = u'' image_url = False shown = False @@ -149,5 +150,7 @@ fileformats = ('jpg', 'jpeg', 'png', 'gif', 'svg', 'ogg') mysite = pywikibot.Site() main(url, image_url, desc) -finally: - pywikibot.stopme() + + +if __name__ == '__main__': + main() diff --git a/scripts/standardize_interwiki.py b/scripts/standardize_interwiki.py index 7ca682f..281c96a 100644 --- a/scripts/standardize_interwiki.py +++ b/scripts/standardize_interwiki.py @@ -9,7 +9,7 @@ """ # # (C) Rob W.W. Hooft, 2003 -# (C) Pywikibot team, 2003-2015 +# (C) Pywikibot team, 2003-2016 # # Distributed under the terms of the MIT license. # @@ -41,27 +41,26 @@ } -# Some parameters -options = list() -start = list() -filelist = list() -hints = {} -debug = 0 -start = '!' -nothing = False +def main(*args): + """Process command line arguments and run the script.""" + # Some parameters + options = list() + start = list() + filelist = list() + hints = {} + debug = 0 + start = '!' + nothing = False -# Load the default parameters and start -for arg in pywikibot.handle_args(): - if arg.startswith('-start'): - if len(arg) == 6: - start = pywikibot.input(u'From what page do you want to start?') - else: - start = arg[7:] -site = pywikibot.Site() -comm = pywikibot.translate(site, comment) - -# What follows is the main part of the code. -try: + # Load the default parameters and start + for arg in pywikibot.handle_args(): + if arg.startswith('-start'): + if len(arg) == 6: + start = pywikibot.input(u'From what page do you want to start?') + else: + start = arg[7:] + site = pywikibot.Site() + comm = pywikibot.translate(site, comment) for pl in site.allpages(start): plname = pl.title() pywikibot.output(u'\nLoading %s...' % plname) @@ -90,5 +89,7 @@ else: pywikibot.output(u'No interwiki found.') continue -finally: - pywikibot.stopme() + + +if __name__ == '__main__': + main() -- To view, visit https://gerrit.wikimedia.org/r/276426 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ice68e65510cc29e797830a1b5cdbf957df29bb40 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: Xqt <i...@gno.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits