本文整理汇总了Python中pywikibot.showHelp函数的典型用法代码示例。如果您正苦于以下问题:Python showHelp函数的具体用法?Python showHelp怎么用?Python showHelp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了showHelp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
oldImage = None
newImage = None
summary = ''
always = False
loose = False
# read command line parameters
for arg in pywikibot.handleArgs():
if arg == '-always':
always = True
elif arg == '-loose':
loose = True
elif arg.startswith('-summary'):
if len(arg) == len('-summary'):
summary = pywikibot.input(u'Choose an edit summary: ')
else:
summary = arg[len('-summary:'):]
else:
if oldImage:
newImage = arg
else:
oldImage = arg
if not oldImage:
pywikibot.showHelp('image')
else:
mysite = pywikibot.getSite()
ns = mysite.image_namespace()
oldImagePage = pywikibot.ImagePage(mysite, ns + ':' + oldImage)
gen = pagegenerators.FileLinksGenerator(oldImagePage)
preloadingGen = pagegenerators.PreloadingGenerator(gen)
bot = ImageRobot(preloadingGen, oldImage, newImage, summary, always,
loose)
bot.run()
示例2: main
def main(*args):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
@type args: list of unicode
"""
global __simulate, __sys_argv
for arg in pywikibot.handle_args(args):
pywikibot.showHelp("script_wui")
return
__simulate = pywikibot.config.simulate
__sys_argv = sys.argv
site = pywikibot.Site()
site.login()
chan = "#" + site.language() + "." + site.family.name
bot = ScriptWUIBot(site, chan, site.user() + "_WUI", "irc.wikimedia.org")
try:
bot.start()
except:
bot.t.cancel()
raise
示例3: main
def main():
""" Process command line arguments and invoke BasicBot. """
# Process global arguments to determine desired site
local_args = pywikibot.handleArgs()
# This factory is responsible for processing command line arguments
# that are also used by other scripts and that determine on which pages
# to work on.
genFactory = pagegenerators.GeneratorFactory()
# The generator gives the pages that should be worked upon.
gen = None
# If dry is True, doesn't do any real changes, but only show
# what would have been changed.
dry = False
# Parse command line arguments
for arg in local_args:
if arg.startswith("-dry"):
dry = True
else:
genFactory.handleArg(arg)
if not gen:
gen = genFactory.getCombinedGenerator()
if gen:
# The preloading generator is responsible for downloading multiple
# pages from the wiki simultaneously.
gen = pagegenerators.PreloadingGenerator(gen)
bot = BasicBot(gen, dry)
bot.run()
else:
pywikibot.showHelp()
示例4: main
def main(*args):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
@type args: list of unicode
"""
# This temporary string is used to read the title
# of the page that should be unlinked.
page_title = None
options = {}
for arg in pywikibot.handle_args(args):
if arg.startswith('-namespace:'):
if 'namespaces' not in options:
options['namespaces'] = []
try:
options['namespaces'].append(int(arg[11:]))
except ValueError:
options['namespaces'].append(arg[11:])
elif arg == '-always':
options['always'] = True
else:
page_title = arg
if page_title:
page = pywikibot.Page(pywikibot.Site(), page_title)
bot = UnlinkBot(page, **options)
bot.run()
else:
pywikibot.showHelp()
示例5: main
def main(*args):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
@type args: list of unicode
"""
gen = None
options = {}
# Process global args and prepare generator args parser
local_args = pywikibot.handle_args(args)
genFactory = pagegenerators.GeneratorFactory()
bot_class = TouchBot
for arg in local_args:
if arg == '-purge':
bot_class = PurgeBot
elif arg == '-redir':
pywikibot.output(u'-redirect option is deprecated, '
'do not use it anymore.')
elif not genFactory.handleArg(arg) and arg.startswith("-"):
options[arg[1:].lower()] = True
gen = genFactory.getCombinedGenerator()
if gen:
preloadingGen = pagegenerators.PreloadingGenerator(gen)
bot = bot_class(generator=preloadingGen, **options)
pywikibot.Site().login()
bot.run()
else:
pywikibot.showHelp()
示例6: main
def main():
featured = False
gen = None
# This factory is responsible for processing command line arguments
# that are also used by other scripts and that determine on which pages
# to work on.
genFactory = pagegenerators.GeneratorFactory()
for arg in pywikibot.handleArgs():
if arg == '-featured':
featured = True
else:
genFactory.handleArg(arg)
mysite = pywikibot.getSite()
if mysite.sitename() == 'wikipedia:nl':
pywikibot.output(
u'\03{lightred}There is consensus on the Dutch Wikipedia that bots should not be used to fix redirects.\03{default}')
sys.exit()
if featured:
featuredList = i18n.translate(mysite, featured_articles)
ref = pywikibot.Page(pywikibot.getSite(), featuredList)
gen = pagegenerators.ReferringPageGenerator(ref)
gen = pagegenerators.NamespaceFilterPageGenerator(gen, [0])
if not gen:
gen = genFactory.getCombinedGenerator()
if gen:
for page in pagegenerators.PreloadingGenerator(gen):
workon(page)
else:
pywikibot.showHelp('fixing_redirects')
示例7: main
def main():
# This temporary string is used to read the title
# of the page that should be unlinked.
page_title = None
options = {}
for arg in pywikibot.handleArgs():
if arg.startswith('-namespace:'):
if 'namespaces' not in options:
options['namespaces'] = []
try:
options['namespaces'].append(int(arg[11:]))
except ValueError:
options['namespaces'].append(arg[11:])
elif arg == '-always':
options['always'] = True
else:
page_title = arg
if page_title:
page = pywikibot.Page(pywikibot.Site(), page_title)
bot = UnlinkBot(page, **options)
bot.run()
else:
pywikibot.showHelp()
示例8: main
def main(*args):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
@type args: list of unicode
"""
options = {}
for arg in pywikibot.handle_args(args):
if arg.startswith('-fromlang:'):
options[arg[1:9]] = arg[10:].split(",")
elif arg.startswith('-after:'):
options['afterpage'] = arg[7:]
elif arg.startswith('-nocache:'):
options[arg[1:8]] = arg[9:].split(",")
else:
options[arg[1:].lower()] = True
if options:
bot = FeaturedBot(**options)
bot.run()
else:
pywikibot.showHelp()
示例9: main
def main(*args):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
@type args: list of unicode
"""
local_args = pywikibot.handle_args(args)
start = local_args[0] if local_args else '!'
mysite = pywikibot.Site()
try:
mysite.disambcategory()
except pywikibot.Error as e:
pywikibot.output(e)
pywikibot.showHelp()
return
generator = pagegenerators.CategorizedPageGenerator(
mysite.disambcategory(), start=start, content=True, namespaces=[0])
bot = DisambiguationRedirectBot(generator=generator)
bot.run()
示例10: main
def main():
#page generator
gen = None
# If the user chooses to work on a single page, this temporary array is
# used to read the words from the page title. The words will later be
# joined with spaces to retrieve the full title.
pageTitle = []
# This factory is responsible for processing command line arguments
# that are also used by other scripts and that determine on which pages
# to work on.
genFactory = pagegenerators.GeneratorFactory()
for arg in pywikibot.handleArgs():
if not genFactory.handleArg(arg):
pageTitle.append(arg)
if pageTitle:
# work on a single page
page = pywikibot.Page(pywikibot.getSite(), ' '.join(pageTitle))
gen = iter([page])
if not gen:
gen = genFactory.getCombinedGenerator()
if not gen:
pywikibot.showHelp('inline_images')
else:
preloadingGen = pagegenerators.PreloadingGenerator(gen)
bot = InlineImagesRobot(preloadingGen)
bot.run()
示例11: main
def main(*args):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
@type args: list of unicode
"""
gen = None
options = {}
# Process global args and prepare generator args parser
local_args = pywikibot.handle_args(args)
genFactory = pagegenerators.GeneratorFactory()
for arg in local_args:
if genFactory.handleArg(arg):
continue
if arg.startswith("-"):
options[arg[1:].lower()] = True
gen = genFactory.getCombinedGenerator()
if gen:
preloadingGen = pagegenerators.PreloadingGenerator(gen)
bot = TouchBot(preloadingGen, **options)
pywikibot.Site().login()
bot.run()
else:
pywikibot.showHelp()
示例12: main
def main(*args):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
@type args: list of unicode
"""
# Process global args and prepare generator args parser
local_args = pywikibot.handle_args(args)
gen = pagegenerators.GeneratorFactory()
options = {}
for arg in local_args:
if (
arg.startswith('-pageage:') or
arg.startswith('-lastedit:')):
key, val = arg.split(':', 1)
options[key[1:]] = int(val)
elif gen.handleArg(arg):
pass
else:
options[arg[1:].lower()] = True
generator = gen.getCombinedGenerator()
if not generator:
pywikibot.showHelp()
return
bot = NewItemRobot(generator, **options)
bot.run()
示例13: main
def main():
opts = {}
for arg in pywikibot.handleArgs():
if arg.startswith('-hours:'):
opts['hours'] = float(arg[7:])
opts['no_repeat'] = False
elif arg.startswith('-delay:'):
opts['delay'] = int(arg[7:])
elif arg.startswith('-page'):
if len(arg) == 5:
opts['page'] = pywikibot.input(
u'Which page do you want to change?')
else:
opts['page'] = arg[6:]
elif arg.startswith('-text'):
if len(arg) == 5:
opts['text'] = pywikibot.input(
u'What text do you want to substitute?')
else:
opts['text'] = arg[6:]
elif arg == '-user':
opts['user'] = True
elif arg.startswith('-summary'):
if len(arg) == len('-summary'):
opts['summary'] = pywikibot.input(u'Enter the summary:')
else:
opts['summary'] = arg[9:]
else:
pywikibot.showHelp('clean_sandbox')
return
bot = SandboxBot(**opts)
bot.run()
示例14: main
def main(*args):
gen = None
genFactory = pagegenerators.GeneratorFactory()
options = {}
# If the user chooses to work on a single page, this temporary array is
# used to read the words from the page title. The words will later be
# joined with spaces to retrieve the full title.
pageTitle = []
for arg in pywikibot.handleArgs(*args):
if genFactory.handleArg(arg):
continue
if arg.startswith("-"):
options[arg[1:].lower()] = True
else:
pageTitle.append(arg)
pywikibot.Site().login()
gen = genFactory.getCombinedGenerator()
if not gen:
if pageTitle:
# work on a single page
page = pywikibot.Page(pywikibot.Link(' '.join(pageTitle)))
gen = iter([page])
else:
pywikibot.showHelp()
return
preloadingGen = pagegenerators.PreloadingGenerator(gen)
bot = TouchBot(preloadingGen, **options)
bot.run()
示例15: __init__
def __init__(self, generator, **kwargs):
self.availableOptions.update({
'enablePage': None, # Check if someone set an enablePage or not
'disambigPage': None, # If no disambigPage given, not use it.
})
super(LonelyPagesBot, self).__init__(**kwargs)
self.generator = generator
# Take the configurations according to our project
self.site = pywikibot.Site()
if self.getOption('enablePage'):
self.options['enablePage'] = pywikibot.Page(
self.site, self.getOption('enablePage'))
self.comment = i18n.twtranslate(
self.site, 'lonelypages-comment-add-template')
self.commentdisambig = i18n.twtranslate(
self.site, 'lonelypages-comment-add-disambig-template')
self.template = i18n.translate(self.site, template)
self.exception = i18n.translate(self.site, exception_regex)
if self.template is None or self.exception is None:
pywikibot.showHelp()
sys.exit(u'Missing configuration for site %s' % self.site)
# DisambigPage part
if self.getOption('disambigPage') is not None:
self.disambigpage = pywikibot.Page(self.site, self.getOption('disambigPage'))
try:
self.disambigtext = self.disambigpage.get()
except pywikibot.NoPage:
pywikibot.output(u"%s doesn't esist, skip!" % self.disambigpage.title())
self.disambigtext = ''
except pywikibot.IsRedirectPage:
pywikibot.output(u"%s is a redirect, don't use it!"
% self.disambigpage.title())
self.options['disambigPage'] = None