jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/494906 )

Change subject: [IMPR] make suggest_help a function
......................................................................

[IMPR] make suggest_help a function

- make suggest_help a function and return True
  if an error message was printed, False otherwise
- change several script to use this functionality
- check scripts to PEP8 about return statements
  and remove the return values which where never used

Change-Id: I6e32a842f99c439e3b27ca51ff171c4419829417
---
M pywikibot/bot.py
M scripts/add_text.py
M scripts/archive/script_wui.py
M scripts/archivebot.py
M scripts/basic.py
M scripts/capitalize_redirects.py
M scripts/category.py
M scripts/checkimages.py
M scripts/claimit.py
M scripts/commons_link.py
M scripts/commonscat.py
M scripts/cosmetic_changes.py
M scripts/create_categories.py
M scripts/data_ingestion.py
M scripts/delete.py
M scripts/disambredir.py
M scripts/djvutext.py
M scripts/fixing_redirects.py
M scripts/illustrate_wikidata.py
M scripts/image.py
M scripts/imagecopy.py
M scripts/imagecopy_self.py
M scripts/imagetransfer.py
M scripts/imageuncat.py
M scripts/interwikidata.py
M scripts/isbn.py
M scripts/listpages.py
M scripts/login.py
M scripts/maintenance/download_dump.py
M scripts/match_images.py
M scripts/movepages.py
M scripts/ndashredir.py
M scripts/newitem.py
M scripts/noreferences.py
M scripts/pagefromfile.py
M scripts/piper.py
M scripts/protect.py
M scripts/reflinks.py
M scripts/replace.py
M scripts/selflink.py
M scripts/solve_disambiguation.py
M scripts/spamremove.py
M scripts/states_redirect.py
M scripts/table2wiki.py
M scripts/templatecount.py
M scripts/touch.py
M scripts/transferbot.py
M scripts/unlink.py
M scripts/unusedfiles.py
M scripts/weblinkchecker.py
M scripts/welcome.py
M scripts/wikisourcetext.py
52 files changed, 78 insertions(+), 140 deletions(-)

Approvals:
  JJMC89: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 6029cc1..2a7023f 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1081,6 +1081,8 @@
     @param missing_dependencies: A list of dependencies which can not
         be imported.
     @type missing_dependencies: list of str
+    @return: True if an error message was printed, False otherwise
+    @rtype: bool
     """
     messages = []
     if exception:
@@ -1108,6 +1110,8 @@
     if messages:
         messages.append('Use -help for further information.')
         error('\n'.join(messages))
+        return True
+    return False


 def writeToCommandLogFile():
diff --git a/scripts/add_text.py b/scripts/add_text.py
index 3eec3a8..04f893f 100755
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -340,13 +340,13 @@
     if textfile and not addText:
         with codecs.open(textfile, 'r', config.textfile_encoding) as f:
             addText = f.read()
+
     generator = genFactory.getCombinedGenerator()
-    if not generator:
-        pywikibot.bot.suggest_help(missing_generator=True)
-        return False
-    if not addText:
-        pywikibot.error("The text to add wasn't given.")
+    additional_text = '' if addText else "The text to add wasn't given."
+    if pywikibot.bot.suggest_help(missing_generator=not generator,
+                                  additional_text=additional_text):
         return
+
     if talkPage:
         generator = pagegenerators.PageWithTalkPageGenerator(generator, True)
     for page in generator:
diff --git a/scripts/archive/script_wui.py b/scripts/archive/script_wui.py
index 25fa9f1..bc997d6 100755
--- a/scripts/archive/script_wui.py
+++ b/scripts/archive/script_wui.py
@@ -357,6 +357,7 @@
     except BaseException:
         bot.t.cancel()
         raise
+    return True


 if __name__ == '__main__':
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index ad075c1..0d74161 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -763,7 +763,7 @@
     if calc:
         if not salt:
             pywikibot.bot.suggest_help(missing_parameters=['-salt'])
-            return False
+            return
         page = pywikibot.Page(site, calc)
         if page.exists():
             calc = page.title()
@@ -777,7 +777,7 @@
     if not templates:
         pywikibot.bot.suggest_help(
             additional_text='No template was specified.')
-        return False
+        return

     for template_name in templates:
         pagelist = []
diff --git a/scripts/basic.py b/scripts/basic.py
index 40b1b9d..6ef72ba 100755
--- a/scripts/basic.py
+++ b/scripts/basic.py
@@ -168,10 +168,8 @@
         # pass generator and private options to the bot
         bot = BasicBot(gen, **options)
         bot.run()  # guess what it does
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/capitalize_redirects.py b/scripts/capitalize_redirects.py
index 76b2e61..e04778d 100755
--- a/scripts/capitalize_redirects.py
+++ b/scripts/capitalize_redirects.py
@@ -110,10 +110,8 @@
     if gen:
         bot = CapitalizeBot(gen, **options)
         bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/category.py b/scripts/category.py
index cc67ebc..41c69a3 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -1554,10 +1554,8 @@
         finally:
             if cat_db:
                 cat_db.dump()
-        return True
     else:
         suggest_help(missing_action=True, unknown_parameters=unknown)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 2c4b6b3..cc7c18c 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -1673,9 +1673,8 @@
                            'project to the "project_inserted" list!')
     else:
         additional_text = ''
-    if unknown or additional_text:
-        suggest_help(unknown_parameters=unknown,
-                     additional_text=additional_text)
+    if suggest_help(unknown_parameters=unknown,
+                    additional_text=additional_text):
         return False

     # Reading the log of the new images if another generator is not given.
diff --git a/scripts/claimit.py b/scripts/claimit.py
index bdef4e1..317a8db 100755
--- a/scripts/claimit.py
+++ b/scripts/claimit.py
@@ -155,11 +155,10 @@
     generator = gen.getCombinedGenerator()
     if not generator:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
+        return

     bot = ClaimRobot(generator, claims, exists_arg)
     bot.run()
-    return True

 
 if __name__ == '__main__':
diff --git a/scripts/commons_link.py b/scripts/commons_link.py
index 2772f02..9859784 100755
--- a/scripts/commons_link.py
+++ b/scripts/commons_link.py
@@ -138,14 +138,12 @@
             gen_factory.handleArg(arg)

     gen = gen_factory.getCombinedGenerator(preload=True)
-    if 'action' in options and gen:
-        bot = CommonsLinkBot(gen, **options)
-        bot.run()
-        return True
+    if pywikibot.bot.suggest_help(missing_action='action' not in options,
+                                  missing_generator=not gen):
+        return

-    pywikibot.bot.suggest_help(missing_action='action' not in options,
-                               missing_generator=not gen)
-    return False
+    bot = CommonsLinkBot(gen, **options)
+    bot.run()


 if __name__ == '__main__':
diff --git a/scripts/commonscat.py b/scripts/commonscat.py
index 80dbc30..c056b29 100755
--- a/scripts/commonscat.py
+++ b/scripts/commonscat.py
@@ -525,10 +525,8 @@
             generator = pagegenerators.PreloadingGenerator(generator)
         bot = CommonscatBot(generator=generator, **options)
         bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index b937764..73a858e 100644
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -29,7 +29,7 @@
 """
 #
 # (C) xqt, 2009-2018
-# (C) Pywikibot team, 2006-2018
+# (C) Pywikibot team, 2006-2019
 #
 # Distributed under the terms of the MIT license.
 #
@@ -130,10 +130,8 @@
             site.login()
             bot = CosmeticChangesBot(gen, **options)
             bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/create_categories.py b/scripts/create_categories.py
index 17c30cb..6027d36 100755
--- a/scripts/create_categories.py
+++ b/scripts/create_categories.py
@@ -128,14 +128,12 @@
                if arg not in options]

     generator = gen_factory.getCombinedGenerator()
-    if generator and not missing:
-        bot = CreateCategoriesBot(generator=generator, **options)
-        bot.run()
-        return True
-    else:
-        pywikibot.bot.suggest_help(missing_parameters=missing,
-                                   missing_generator=not generator)
-        return False
+    if pywikibot.bot.suggest_help(missing_parameters=missing,
+                                  missing_generator=not generator):
+        return
+
+    bot = CreateCategoriesBot(generator=generator, **options)
+    bot.run()


 if __name__ == '__main__':
diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py
index 886de71..abded22 100755
--- a/scripts/data_ingestion.py
+++ b/scripts/data_ingestion.py
@@ -270,12 +270,11 @@
     else:
         missing_dependencies = None

-    if not config_generator or not csv_dir or missing_dependencies:
-        pywikibot.bot.suggest_help(
+    if pywikibot.bot.suggest_help(
             missing_parameters=[] if csv_dir else ['-csvdir'],
             missing_generator=not config_generator,
-            missing_dependencies=missing_dependencies)
-        return False
+            missing_dependencies=missing_dependencies):
+        return

     for config_page in config_generator:
         try:
diff --git a/scripts/delete.py b/scripts/delete.py
index effe936..8803b8c 100755
--- a/scripts/delete.py
+++ b/scripts/delete.py
@@ -300,10 +300,8 @@
                                               .get('undelete', False)]))
         bot = DeletionRobot(generator, summary, **options)
         bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/disambredir.py b/scripts/disambredir.py
index ae33c71..4837ce0 100755
--- a/scripts/disambredir.py
+++ b/scripts/disambredir.py
@@ -77,7 +77,7 @@
         mysite.disambcategory()
     except pywikibot.Error as e:
         pywikibot.bot.suggest_help(exception=e)
-        return False
+        return

     generator = pagegenerators.CategorizedPageGenerator(
         mysite.disambcategory(), start=start, content=True, namespaces=[0])
diff --git a/scripts/djvutext.py b/scripts/djvutext.py
index 0d0be22..0ef9519 100644
--- a/scripts/djvutext.py
+++ b/scripts/djvutext.py
@@ -159,14 +159,14 @@
     # index is mandatory.
     if not index:
         pywikibot.bot.suggest_help(missing_parameters=['-index'])
-        return False
+        return

     # If djvu_path is not a file, build djvu_path from dir+index.
     djvu_path = os.path.expanduser(djvu_path)
     djvu_path = os.path.abspath(djvu_path)
     if not os.path.exists(djvu_path):
         pywikibot.error('No such file or directory: ' + djvu_path)
-        return False
+        return
     if os.path.isdir(djvu_path):
         djvu_path = os.path.join(djvu_path, index)

@@ -176,7 +176,7 @@
     if not djvu.has_text():
         pywikibot.error('No text layer in djvu file {}'
                         .format(djvu.file_djvu))
-        return False
+        return

     # Parse pages param.
     pages = pages.split(',')
@@ -193,7 +193,7 @@
     if not site.has_extension('ProofreadPage'):
         pywikibot.error('Site {} must have ProofreadPage extension.'
                         .format(site))
-        return False
+        return

     index_page = pywikibot.Page(site, index, ns=site.proofread_index_ns)

diff --git a/scripts/fixing_redirects.py b/scripts/fixing_redirects.py
index 226e336..5d2028a 100755
--- a/scripts/fixing_redirects.py
+++ b/scripts/fixing_redirects.py
@@ -211,10 +211,8 @@
     if gen:
         bot = FixingRedirectBot(generator=gen)
         bot.run()
-        return True
     else:
         suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/illustrate_wikidata.py b/scripts/illustrate_wikidata.py
index 1e97d59..93a4875 100755
--- a/scripts/illustrate_wikidata.py
+++ b/scripts/illustrate_wikidata.py
@@ -111,11 +111,10 @@
     generator = generator_factory.getCombinedGenerator(preload=True)
     if not generator:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
+        return

     bot = IllustrateRobot(generator, wdproperty)
     bot.run()
-    return True


 if __name__ == '__main__':
diff --git a/scripts/image.py b/scripts/image.py
index 6ad29e6..5f8f2cd 100755
--- a/scripts/image.py
+++ b/scripts/image.py
@@ -161,10 +161,8 @@
         bot = ImageRobot(preloading_gen, old_image, new_image,
                          site=site, **options)
         bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_parameters=['old image'])
-        return False


 if __name__ == '__main__':
diff --git a/scripts/imagecopy.py b/scripts/imagecopy.py
index efadd9e..1223f4b 100644
--- a/scripts/imagecopy.py
+++ b/scripts/imagecopy.py
@@ -518,7 +518,7 @@
     pregenerator = genFactory.getCombinedGenerator(preload=True)
     if not pregenerator:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
+        return

     load_global_archivo()

diff --git a/scripts/imagecopy_self.py b/scripts/imagecopy_self.py
index afe7ae2..c6beace 100644
--- a/scripts/imagecopy_self.py
+++ b/scripts/imagecopy_self.py
@@ -56,6 +56,7 @@
 import webbrowser

 from datetime import datetime
+from textwrap import fill

 import pywikibot

@@ -1045,18 +1046,16 @@
             genFactory.handleArg(arg)

     pregenerator = genFactory.getCombinedGenerator(preload=True)
-    if not pregenerator:
-        pywikibot.bot.suggest_help(missing_generator=True)
-        return False
+    additional_text = ('' if supportedSite()
+                       else 'Sorry, this site is not supported (yet).')
+    if pywikibot.bot.suggest_help(missing_generator=not pregenerator,
+                                  additional_text=additional_text):
+        return

-    if not supportedSite():
-        pywikibot.output('Sorry, this site is not supported (yet).')
-        return False
-
-    pywikibot.warning('This is an experimental bot')
-    pywikibot.warning('It will only work on self published work images')
-    pywikibot.warning('This bot is still full of bugs')
-    pywikibot.warning('Use at your own risk!')
+    pywikibot.warning(fill('This is an experimental bot. '
+                           'It will only work on self published work images. '
+                           'This bot is still full of bugs. '
+                           'Use at your own risk!'))

     prefetchQueue = Queue(maxsize=50)
     uploadQueue = Queue(maxsize=200)
diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py
index f89e8ba..2c34142 100755
--- a/scripts/imagetransfer.py
+++ b/scripts/imagetransfer.py
@@ -326,7 +326,7 @@
         pywikibot.bot.suggest_help(
             missing_parameters=['page'],
             additional_text='and no other generator was defined.')
-        return False
+        return

     site = pywikibot.Site()
     if not targetLang and not targetFamily:
diff --git a/scripts/imageuncat.py b/scripts/imageuncat.py
index 31baaa8..c8f6151 100755
--- a/scripts/imageuncat.py
+++ b/scripts/imageuncat.py
@@ -1369,7 +1369,6 @@
     generator = gen_factory.getCombinedGenerator(gen=generator, preload=True)
     if not generator:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
     else:
         site.login()
         for page in generator:
@@ -1378,7 +1377,6 @@
                     and (not page.isRedirectPage()):
                 if isUncat(page):
                     addUncat(page)
-        return True


 if __name__ == '__main__':
diff --git a/scripts/interwikidata.py b/scripts/interwikidata.py
index bcc1d27..d7897ba 100644
--- a/scripts/interwikidata.py
+++ b/scripts/interwikidata.py
@@ -239,7 +239,6 @@
         bot.run()
     else:
         suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/isbn.py b/scripts/isbn.py
index 8dbb61c..40ad1ae 100755
--- a/scripts/isbn.py
+++ b/scripts/isbn.py
@@ -35,7 +35,7 @@

 """
 #
-# (C) Pywikibot team, 2009-2018
+# (C) Pywikibot team, 2009-2019
 #
 # Distributed under the terms of the MIT license.
 #
@@ -1674,10 +1674,8 @@
         else:
             bot = IsbnBot(gen, **options)
         bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/listpages.py b/scripts/listpages.py
index cf20cd6..57614ea 100755
--- a/scripts/listpages.py
+++ b/scripts/listpages.py
@@ -277,10 +277,8 @@
             page_target.save(summary=summary)
         pywikibot.stdout(text)
         pywikibot.output('{0} page(s) found'.format(i))
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False

 
 if __name__ == '__main__':
diff --git a/scripts/login.py b/scripts/login.py
index edf820e..2328206 100755
--- a/scripts/login.py
+++ b/scripts/login.py
@@ -56,7 +56,7 @@
 """
 #
 # (C) Rob W.W. Hooft, 2003
-# (C) Pywikibot team, 2003-2018
+# (C) Pywikibot team, 2003-2019
 #
 # Distributed under the terms of the MIT license.
 #
@@ -151,9 +151,8 @@
         else:
             unknown_args += [arg]

-    if unknown_args:
-        pywikibot.bot.suggest_help(unknown_parameters=unknown_args)
-        return False
+    if pywikibot.bot.suggest_help(unknown_parameters=unknown_args):
+        return

     if password is not None:
         pywikibot.warning('The -pass argument is not implemented yet. See: '
diff --git a/scripts/maintenance/download_dump.py 
b/scripts/maintenance/download_dump.py
index d0c72b3..a8ca43a 100644
--- a/scripts/maintenance/download_dump.py
+++ b/scripts/maintenance/download_dump.py
@@ -235,10 +235,9 @@
     if 'filename' not in opts:
         missing += ['-filename']

-    if missing or unknown_args:
-        pywikibot.bot.suggest_help(missing_parameters=missing,
-                                   unknown_parameters=unknown_args)
-        return 1
+    if pywikibot.bot.suggest_help(missing_parameters=missing,
+                                  unknown_parameters=unknown_args):
+        return

     site = pywikibot.Site()
     opts['wikiname'] = site.dbName()
@@ -246,8 +245,6 @@
     bot = DownloadDumpBot(**opts)
     bot.run()

-    return 0
-

 if __name__ == '__main__':
     sys.exit(main())
diff --git a/scripts/match_images.py b/scripts/match_images.py
index 08981a7..30ca5a9 100755
--- a/scripts/match_images.py
+++ b/scripts/match_images.py
@@ -171,10 +171,9 @@
     missing_dependencies = ('Pillow',) if isinstance(
         Image, ImportError) else None

-    if additional_text or missing_dependencies:
-        suggest_help(missing_dependencies=missing_dependencies,
-                     additional_text=additional_text)
-        return False
+    if suggest_help(missing_dependencies=missing_dependencies,
+                    additional_text=additional_text):
+        return

     imagePageA = pywikibot.page.FilePage(pywikibot.Site(),
                                          images[0])
diff --git a/scripts/movepages.py b/scripts/movepages.py
index 0a4124f..d4cdaad 100755
--- a/scripts/movepages.py
+++ b/scripts/movepages.py
@@ -258,13 +258,8 @@
     if gen:
         bot = MovePagesBot(gen, **options)
         bot.run()
-        return True
-
-    if not fromToPairs:
+    elif not fromToPairs:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
-    else:
-        return True


 if __name__ == '__main__':
diff --git a/scripts/ndashredir.py b/scripts/ndashredir.py
index ed5674c..d407b9e 100644
--- a/scripts/ndashredir.py
+++ b/scripts/ndashredir.py
@@ -161,10 +161,8 @@
         # pass generator and private options to the bot
         bot = DashRedirectBot(gen, **options)
         bot.run()  # guess what it does
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/newitem.py b/scripts/newitem.py
index 712b71e..f38fe67 100755
--- a/scripts/newitem.py
+++ b/scripts/newitem.py
@@ -153,7 +153,7 @@
     generator = gen.getCombinedGenerator(preload=True)
     if not generator:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
+        return

     bot = NewItemRobot(generator, **options)
     user = pywikibot.User(bot.site, bot.site.username())
@@ -168,7 +168,6 @@
             .format(user.username, bot.site.sitename)))
         bot.options['touch'] = False
     bot.run()
-    return True


 if __name__ == '__main__':
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index cd290bc..cfe873a 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -780,10 +780,8 @@
     if gen:
         bot = NoReferencesBot(gen, **options)
         bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index a28d441..d9926b9 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -62,7 +62,7 @@
 """
 #
 # (C) Andre Engels, 2004
-# (C) Pywikibot team, 2005-2018
+# (C) Pywikibot team, 2005-2019
 #
 # Distributed under the terms of the MIT license.
 #
@@ -344,7 +344,6 @@
     # or User quit.
     if failed_filename:
         pywikibot.bot.suggest_help(missing_parameters=['-file'])
-        return False
     else:
         reader = PageFromFileReader(filename, **r_options)
         bot = PageFromFileRobot(generator=reader, **options)
diff --git a/scripts/piper.py b/scripts/piper.py
index 1a47f42..726e9f7 100755
--- a/scripts/piper.py
+++ b/scripts/piper.py
@@ -149,10 +149,8 @@
         # pages from the wiki simultaneously.
         bot = PiperBot(gen, **options)
         bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
 

 if __name__ == '__main__':
diff --git a/scripts/protect.py b/scripts/protect.py
index 7623166..6c86696 100755
--- a/scripts/protect.py
+++ b/scripts/protect.py
@@ -246,10 +246,8 @@
                 'Enter a reason for the protection change:')
         bot = ProtectionRobot(generator, combined_protections, site, **options)
         bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index 9095be7..a147fd6 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -814,13 +814,12 @@
         generator = gen_factory.getCombinedGenerator()
     if not generator:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
+        return
     if not gen_factory.nopreload:
         generator = pagegenerators.PreloadingGenerator(generator)
     generator = pagegenerators.RedirectFilterPageGenerator(generator)
     bot = ReferencesRobot(generator, **options)
     bot.run()
-    return True


 if __name__ == '__main__':
diff --git a/scripts/replace.py b/scripts/replace.py
index 237c317..1c30090 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -1193,7 +1193,7 @@

     if not gen:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
+        return

     bot = ReplaceRobot(gen, replacements, exceptions,
                        allowoverlap, recursive, add_cat, sleep, edit_summary,
diff --git a/scripts/selflink.py b/scripts/selflink.py
index e7bffc4..2bb28c1 100755
--- a/scripts/selflink.py
+++ b/scripts/selflink.py
@@ -96,11 +96,10 @@
     gen = gen_factory.getCombinedGenerator(preload=True)
     if not gen:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
+        return

     bot = SelflinkBot(gen, **bot_args)
     bot.run()
-    return True


 if __name__ == '__main__':
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index 3e6d5fe..4e83aba 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -1292,7 +1292,7 @@

     if not generator:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False
+        return

     site.login()

diff --git a/scripts/spamremove.py b/scripts/spamremove.py
index bcabbe0..47a11cd 100755
--- a/scripts/spamremove.py
+++ b/scripts/spamremove.py
@@ -146,7 +146,7 @@

     if not spam_external_url:
         pywikibot.bot.suggest_help(missing_parameters=['spam site'])
-        return False
+        return

     link_search = pagegenerators.LinksearchPageGenerator(spam_external_url,
                                                          protocol=protocol)
diff --git a/scripts/states_redirect.py b/scripts/states_redirect.py
index 8f4ac5b..6c3bbcd 100755
--- a/scripts/states_redirect.py
+++ b/scripts/states_redirect.py
@@ -17,7 +17,7 @@
 """
 #
 # (C) Andre Engels, 2004
-# (C) Pywikibot team, 2004-2018
+# (C) Pywikibot team, 2004-2019
 #
 # Distributed under the terms of the MIT license.
 #
@@ -139,9 +139,8 @@
     else:
         missing_dependencies = None

-    if missing_dependencies or unknown_parameters:
-        suggest_help(unknown_parameters=unknown_parameters,
-                     missing_dependencies=missing_dependencies)
+    if suggest_help(unknown_parameters=unknown_parameters,
+                    missing_dependencies=missing_dependencies):
         return

     bot = StatesRedirectBot(start, force)
diff --git a/scripts/table2wiki.py b/scripts/table2wiki.py
index f1f39e3..d0c63d3 100644
--- a/scripts/table2wiki.py
+++ b/scripts/table2wiki.py
@@ -578,10 +578,8 @@
             gen = pagegenerators.PreloadingGenerator(gen)
         bot = Table2WikiRobot(generator=gen, **options)
         bot.run()
-        return True
     else:
         suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/templatecount.py b/scripts/templatecount.py
index a049ec3..1fdd7f2 100755
--- a/scripts/templatecount.py
+++ b/scripts/templatecount.py
@@ -175,7 +175,7 @@

     if not operation:
         pywikibot.bot.suggest_help(missing_parameters=['operation'])
-        return False
+        return

     robot = TemplateCountRobot()
     if not args_list:
diff --git a/scripts/touch.py b/scripts/touch.py
index b610845..9e2b130 100755
--- a/scripts/touch.py
+++ b/scripts/touch.py
@@ -122,10 +122,8 @@
         bot = bot_class(generator=gen, **options)
         pywikibot.Site().login()
         bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/transferbot.py b/scripts/transferbot.py
index 209717c..2be0a4c 100755
--- a/scripts/transferbot.py
+++ b/scripts/transferbot.py
@@ -103,10 +103,9 @@

     gen = gen_factory.getCombinedGenerator()

-    suggest_help(missing_generator=not gen,
-                 additional_text=additional_text,
-                 unknown_parameters=unknown_args)
-    if additional_text or not gen or unknown_args:
+    if suggest_help(missing_generator=not gen,
+                    additional_text=additional_text,
+                    unknown_parameters=unknown_args):
         return

     gen_args = ' '.join(gen_args)
diff --git a/scripts/unlink.py b/scripts/unlink.py
index dd45f4a..a1463fa 100755
--- a/scripts/unlink.py
+++ b/scripts/unlink.py
@@ -88,10 +88,8 @@
         page = pywikibot.Page(pywikibot.Site(), page_title)
         bot = UnlinkBot(page, **options)
         bot.run()
-        return True
     else:
         pywikibot.bot.suggest_help(missing_parameters=['page title'])
-        return False


 if __name__ == '__main__':
diff --git a/scripts/unusedfiles.py b/scripts/unusedfiles.py
index 86ad136..b51c08a 100755
--- a/scripts/unusedfiles.py
+++ b/scripts/unusedfiles.py
@@ -149,9 +149,6 @@
         bot.run()
     except pywikibot.Error as e:
         pywikibot.bot.suggest_help(exception=e)
-        return False
-    else:
-        return True


 if __name__ == '__main__':
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index f5f6977..db0556a 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -1044,10 +1044,8 @@
                     bot.history.reportThread.kill()
             pywikibot.output('Saving history...')
             bot.history.save()
-        return True
     else:
         suggest_help(missing_generator=True)
-        return False


 if __name__ == '__main__':
diff --git a/scripts/welcome.py b/scripts/welcome.py
index 94b2eaf..0de2639 100755
--- a/scripts/welcome.py
+++ b/scripts/welcome.py
@@ -1026,7 +1026,7 @@
     except KeyError as error:
         # site not managed by welcome.py
         pywikibot.bot.suggest_help(exception=error)
-        return False
+        return

     try:
         bot.run()
diff --git a/scripts/wikisourcetext.py b/scripts/wikisourcetext.py
index 074ce6a..6d16ee6 100644
--- a/scripts/wikisourcetext.py
+++ b/scripts/wikisourcetext.py
@@ -247,24 +247,24 @@
     # index is mandatory.
     if not index:
         pywikibot.bot.suggest_help(missing_parameters=['-index'])
-        return False
+        return

     # '-force' can be used with '-ocr' only.
     if 'force' in options and 'ocr' not in options:
         pywikibot.error("'-force' can be used with '-ocr' option only.")
-        return False
+        return

     site = pywikibot.Site()
     if not site.has_extension('ProofreadPage'):
         pywikibot.error('Site {} must have ProofreadPage extension.'
                         .format(site))
-        return False
+        return

     index = IndexPage(site, index)

     if not index.exists():
         pywikibot.error("Page {} doesn't exist.".format(index))
-        return False
+        return

     # Parse pages param.
     # Create a list of (start, end) tuples.

--
To view, visit https://gerrit.wikimedia.org/r/494906
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6e32a842f99c439e3b27ca51ff171c4419829417
Gerrit-Change-Number: 494906
Gerrit-PatchSet: 10
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Dvorapa <[email protected]>
Gerrit-Reviewer: JJMC89 <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot (75)
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to