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

Change subject: [cleanup] Use suggest_help to suggest help in transferbot.py
......................................................................

[cleanup] Use suggest_help to suggest help in transferbot.py

Use commonly used suggest_help instead of exception handling

Change-Id: Ie60c617d26696079c86560abcdab726f011568d4
---
M scripts/transferbot.py
1 file changed, 11 insertions(+), 45 deletions(-)

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



diff --git a/scripts/transferbot.py b/scripts/transferbot.py
index da21cda..8bf29bf 100755
--- a/scripts/transferbot.py
+++ b/scripts/transferbot.py
@@ -47,40 +47,12 @@
 from __future__ import absolute_import, division, unicode_literals

 import pywikibot
+from pywikibot.bot import suggest_help
 from pywikibot import pagegenerators

 docuReplacements = {'&params;': pagegenerators.parameterHelp}  # noqa: N816


-class WikiTransferException(Exception):
-
-    """Base class for exceptions from this script.
-
-    Makes it easier for clients to catch all expected exceptions that the
-    script might throw
-    """
-
-    pass
-
-
-class TargetSiteMissing(WikiTransferException):
-
-    """Thrown when the target site is the same as the source site.
-
-    Based on the way each are initialized, this is likely to happen when the
-    target site simply hasn't been specified.
-    """
-
-    pass
-
-
-class TargetPagesMissing(WikiTransferException):
-
-    """Thrown if no page range has been specified to operate on."""
-
-    pass
-
-
 def main(*args):
     """
     Process command line arguments and invoke bot.
@@ -114,13 +86,16 @@
         elif arg == '-overwrite':
             overwrite = True

-    tosite = pywikibot.Site(tolang, tofamily)
-    if fromsite == tosite:
-        raise TargetSiteMissing('Target site not different from source site')
-
     gen = gen_factory.getCombinedGenerator()
-    if not gen:
-        raise TargetPagesMissing('Target pages not specified')
+
+    tosite = pywikibot.Site(tolang, tofamily)
+    additional_text = ('Target site not different from source site.'
+                       if fromsite == tosite else '')
+
+    if additional_text or not gen:
+        suggest_help(missing_generator=not gen,
+                     additional_text=additional_text)
+        return

     gen_args = ' '.join(gen_args)
     pywikibot.output("""
@@ -180,13 +155,4 @@


 if __name__ == '__main__':
-    try:
-        main()
-    except TargetSiteMissing:
-        pywikibot.error('Need to specify a target site and/or language')
-        pywikibot.error('Try running this script with -help for help/usage')
-        pywikibot.exception()
-    except TargetPagesMissing:
-        pywikibot.error('Need to specify a page range')
-        pywikibot.error('Try running this script with -help for help/usage')
-        pywikibot.exception()
+    main()

--
To view, visit https://gerrit.wikimedia.org/r/513753
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: Ie60c617d26696079c86560abcdab726f011568d4
Gerrit-Change-Number: 513753
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Dalba <[email protected]>
Gerrit-Reviewer: Dvorapa <[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