jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/502504 )
Change subject: [IMPR] Improvements for catall.py ......................................................................
[IMPR] Improvements for catall.py
- IsRedirectPage exception is to far away from try statement - use print statement for heading line only once in the code - simplify list comparisons
Change-Id: I3b2dfd3aa856ef9804d7c6c20a237d21b14e211f --- M scripts/catall.py 1 file changed, 9 insertions(+), 8 deletions(-)
Approvals: D3r1ck01: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/catall.py b/scripts/catall.py index b019976..a90ed29 100755 --- a/scripts/catall.py +++ b/scripts/catall.py @@ -21,7 +21,7 @@ """ # # (C) Rob W.W. Hooft, Andre Engels, 2004 -# (C) Pywikibot team, 2004-2018 +# (C) Pywikibot team, 2004-2019 # # Distributed under the terms of the MIT license. # @@ -59,7 +59,7 @@ elif choice == '??': pywikibot.output(pagetext[0:length]) length = length + 500 - elif choice == 'xx' and chosen == []: + elif choice == 'xx' and not chosen: chosen = None done = True elif choice == 'q': @@ -106,26 +106,27 @@ for p in mysite.allpages(start=start): try: text = p.get() + except pywikibot.IsRedirectPage: + pywikibot.output('{} is a redirect'.format(p.title())) + else: + pywikibot.output('========== {} =========='.format(p.title())) cats = p.categories() + if not cats: - pywikibot.output('========== {} =========='.format(p.title())) pywikibot.output('No categories') pywikibot.output('-' * 40) newcats = choosecats(text) - if newcats != [] and newcats is not None: + if newcats: make_categories(p, newcats, mysite) elif docorrections: - pywikibot.output('========== {} =========='.format(p.title())) for c in cats: pywikibot.output(c.title()) pywikibot.output('-' * 40) newcats = choosecats(text) if newcats is None: make_categories(p, [], mysite) - elif newcats != []: + elif newcats: make_categories(p, newcats, mysite) - except pywikibot.IsRedirectPage: - pywikibot.output('{} is a redirect'.format(p.title()))
if __name__ == '__main__':