jenkins-bot has submitted this change and it was merged.
Change subject: call pywikibot.showHelp() instead of raising NoEnoughData ......................................................................
call pywikibot.showHelp() instead of raising NoEnoughData
in add_text.py and commonscat.py
- the expected failures were removed from script_tests.py
- the 'addText' argument of add_text.add_text() is now mandatory
bug: 69091 Change-Id: I23f8a29ad5864be6ff649ad7a2c59e0810d9c7c3 --- M scripts/add_text.py M scripts/commonscat.py M tests/script_tests.py 3 files changed, 12 insertions(+), 21 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/add_text.py b/scripts/add_text.py index a8aca2f..cd12b4b 100644 --- a/scripts/add_text.py +++ b/scripts/add_text.py @@ -117,15 +117,9 @@ ]
-class NoEnoughData(pywikibot.Error): - """ Error class for when the user doesn't specified all the data needed """ - - -def add_text(page=None, addText=None, summary=None, regexSkip=None, +def add_text(page=None, addText, summary=None, regexSkip=None, regexSkipUrl=None, always=False, up=False, putText=True, oldTextGiven=None, reorderEnabled=True, create=False): - if not addText: - raise NoEnoughData('You have to specify what text you want to add!') site = page.site if not summary: summary = i18n.twtranslate(site, 'add_text-adding', @@ -350,8 +344,8 @@ if not generator: generator = genFactory.getCombinedGenerator() if not generator: - raise NoEnoughData( - 'You have to specify the generator you want to use for the script!') + pywikibot.showHelp() + return if talkPage: generator = pagegenerators.PageWithTalkPageGenerator(generator) site = pywikibot.Site() diff --git a/scripts/commonscat.py b/scripts/commonscat.py index 09b892d..082cb9b 100755 --- a/scripts/commonscat.py +++ b/scripts/commonscat.py @@ -56,7 +56,7 @@ # # (C) Multichill, 2008-2009 # (C) Xqt, 2009-2014 -# (C) Pywikibot team, 2008-2012 +# (C) Pywikibot team, 2008-2014 # # Distributed under the terms of the MIT license. # @@ -574,13 +574,14 @@
if not generator: generator = genFactory.getCombinedGenerator() - if not generator: - raise add_text.NoEnoughData(u'You have to specify the generator you ' - u'want to use for the script!')
- pregenerator = pagegenerators.PreloadingGenerator(generator) - bot = CommonscatBot(pregenerator, always, summary) - bot.run() + if generator: + pregenerator = pagegenerators.PreloadingGenerator(generator) + bot = CommonscatBot(pregenerator, always, summary) + bot.run() + else: + pywikibot.showHelp() +
if __name__ == "__main__": main() diff --git a/tests/script_tests.py b/tests/script_tests.py index 57f860e..ded3821 100644 --- a/tests/script_tests.py +++ b/tests/script_tests.py @@ -102,9 +102,7 @@ # Some of these are not pretty, but at least they are informative # and not backtraces starting deep in the pywikibot package. no_args_expected_results = { - 'add_text': 'NoEnoughData', 'archivebot': 'NOTE: you must specify a template to run the bot', - 'commonscat': 'add_text.NoEnoughData', 'create_categories': 'No pages to work on', # TODO: until done here, remember to set editor = None in user_config.py 'editarticle': 'Nothing changed', # This masks related bug 68645 but that @@ -217,9 +215,7 @@ test_name = 'test_' + script_name + '_no_args' dct[test_name] = test_execution(script_name, ['-simulate'], no_args_expected_results) - if script_name in ['add_text', # raises custom NoEnoughData - 'checkimages', # bug 68613 - 'commonscat', # raises custom NoEnoughData + if script_name in ['checkimages', # bug 68613 'data_ingestion', # bug 68611 'disambredir', # quittable auto-run with # highly variable output.