jenkins-bot has submitted this change and it was merged.
Change subject: add ability for custom module name in pywikibot.showHelp ......................................................................
add ability for custom module name in pywikibot.showHelp
Change-Id: I37b5f521d508be12bc1a787eb89ebdef10824e63 --- M pywikibot/bot.py 1 file changed, 10 insertions(+), 10 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py index 2e7e859..2c2e2b5 100644 --- a/pywikibot/bot.py +++ b/pywikibot/bot.py @@ -662,14 +662,14 @@ return nonGlobalArgs
-def showHelp(name=""): - # argument, if given, is ignored - modname = calledModuleName() - if not modname: +def showHelp(module_name=None): + if not module_name: + module_name = calledModuleName() + if not module_name: try: - modname = sys.modules['__main__'].main.__module__ + module_name = sys.modules['__main__'].main.__module__ except NameError: - modname = "no_module" + module_name = "no_module"
globalHelp = u''' Global arguments available for all bots: @@ -727,17 +727,17 @@ -<config var>:n You may use all given numeric config variables as option and modify it with command line.
-''' % modname +''' % module_name try: - module = __import__('%s' % modname) + module = __import__('%s' % module_name) helpText = module.__doc__.decode('utf-8') if hasattr(module, 'docuReplacements'): for key, value in module.docuReplacements.items(): helpText = helpText.replace(key, value.strip('\n\r')) pywikibot.stdout(helpText) # output to STDOUT except Exception: - if modname: - pywikibot.stdout(u'Sorry, no help available for %s' % modname) + if module_name: + pywikibot.stdout(u'Sorry, no help available for %s' % module_name) pywikibot.log('showHelp:', exc_info=True) pywikibot.stdout(globalHelp)
pywikibot-commits@lists.wikimedia.org