本文整理汇总了Python中wikipedia.handleArgs函数的典型用法代码示例。如果您正苦于以下问题:Python handleArgs函数的具体用法?Python handleArgs怎么用?Python handleArgs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了handleArgs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
'''
The main loop
'''
wikipedia.handleArgs()
conn = None
cursor = None
(conn, cursor) = connectDatabase()
for templateTitle in getUncategorizedTemplates(cursor):
tagUncategorized(templateTitle)
开发者ID:bymerej,项目名称:ts-multichill-bot,代码行数:10,代码来源:tag_uncategorized_templates.py
示例2: main
def main():
'''
The main loop
'''
wikipedia.handleArgs()
conn = None
cursor = None
(conn, cursor) = connectDatabase()
imageList = getImagesToNowcommons(cursor)
for (wImage, cImage, timestamp) in imageList:
tagNowCommons(unicode(wImage, 'utf-8'), unicode(cImage, 'utf-8'), timestamp)
开发者ID:multichill,项目名称:toollabs,代码行数:11,代码来源:tag_nowcommons.py
示例3: 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()
开发者ID:Botomatik,项目名称:JackBot,代码行数:28,代码来源:inline_images.py
示例4: main
def main():
operation = None
argsList = []
namespaces = []
for arg in wikipedia.handleArgs():
if arg == '-count':
operation = "Count"
elif arg == '-list':
operation = "List"
elif arg.startswith('-namespace:'):
try:
namespaces.append(int(arg[len('-namespace:'):]))
except ValueError:
namespaces.append(arg[len('-namespace:'):])
else:
argsList.append(arg)
if operation == None:
wikipedia.showHelp('templatecount')
else:
robot = TemplateCountRobot()
if not argsList:
argsList = ['ref', 'note', 'ref label', 'note label']
if operation == "Count":
robot.countTemplates(argsList, namespaces)
elif operation == "List":
robot.listTemplates(argsList, namespaces)
开发者ID:pyropeter,项目名称:PyroBot-1G,代码行数:28,代码来源:templatecount.py
示例5: main
def main(*args):
# Disable cosmetic changes because we don't want to modify any page
# content, so that we don't flood the histories with minor changes.
config.cosmetic_changes = False
#page generator
gen = None
genFactory = pagegenerators.GeneratorFactory()
redirs = False
# 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 == '-redir':
redirs = True
else:
pageTitle.append(arg)
gen = genFactory.getCombinedGenerator()
if not gen:
if pageTitle:
# work on a single page
page = pywikibot.Page(pywikibot.getSite(), ' '.join(pageTitle))
gen = iter([page])
else:
pywikibot.showHelp()
return
preloadingGen = pagegenerators.PreloadingGenerator(gen)
bot = TouchBot(preloadingGen, redirs)
bot.run()
开发者ID:Rodehi,项目名称:GFROS,代码行数:32,代码来源:touch.py
示例6: main
def main():
countrycode = u''
# Connect database, we need that
(conn, cursor) = connectDatabase()
(conn2, cursor2) = connectDatabase2()
generator = None
genFactory = pagegenerators.GeneratorFactory()
for arg in wikipedia.handleArgs():
if arg.startswith('-countrycode:'):
countrycode = arg [len('-countrycode:'):]
lang = wikipedia.getSite().language()
wikipedia.setSite(wikipedia.getSite(u'commons', u'commons'))
if countrycode:
if not mconfig.countries.get((countrycode, lang)):
wikipedia.output(u'I have no config for countrycode "%s" in language "%s"' % (countrycode, lang))
return False
wikipedia.output(u'Working on countrycode "%s" in language "%s"' % (countrycode, lang))
locateCountry(countrycode, lang, mconfig.countries.get((countrycode, lang)), conn, cursor, conn2, cursor2)
else:
for (countrycode, lang), countryconfig in mconfig.countries.iteritems():
if not countryconfig.get('autoGeocode'):
wikipedia.output(u'"%s" in language "%s" is not supported in auto geocode mode (yet).' % (countrycode, lang))
else:
wikipedia.output(u'Working on countrycode "%s" in language "%s"' % (countrycode, lang))
locateCountry(countrycode, lang, countryconfig, conn, cursor, conn2, cursor2)
开发者ID:ranjithsiji,项目名称:wikimedia-wlm-api,代码行数:30,代码来源:add_object_location_monuments.py
示例7: main
def main(args):
'''
Main loop. Get a generator and options. Work on all images in the generator.
'''
generator = None
onlyFilter = False
onlyUncat = False
genFactory = pagegenerators.GeneratorFactory()
global search_wikis
global hint_wiki
site = pywikibot.getSite(u'commons', u'commons')
pywikibot.setSite(site)
for arg in pywikibot.handleArgs():
if arg == '-onlyfilter':
onlyFilter = True
elif arg == '-onlyuncat':
onlyUncat = True
elif arg.startswith('-hint:'):
hint_wiki = arg [len('-hint:'):]
elif arg.startswith('-onlyhint'):
search_wikis = arg [len('-onlyhint:'):]
else:
genFactory.handleArg(arg)
generator = genFactory.getCombinedGenerator()
if not generator:
generator = pagegenerators.CategorizedPageGenerator(
catlib.Category(site, u'Category:Media needing categories'),
recurse=True)
initLists()
categorizeImages(generator, onlyFilter, onlyUncat)
pywikibot.output(u'All done')
开发者ID:swertschak,项目名称:wikijournals-api,代码行数:34,代码来源:imagerecat.py
示例8: main
def main():
global always
always = False
for arg in pywikibot.handleArgs():
if arg == '-always':
always = True
mysite = pywikibot.getSite()
# If anything needs to be prepared, you can do it here
template_image = pywikibot.translate(pywikibot.getSite(),
template_to_the_image)
template_user = pywikibot.translate(pywikibot.getSite(),
template_to_the_user)
except_text_translated = pywikibot.translate(pywikibot.getSite(),
except_text)
basicgenerator = pagegenerators.UnusedFilesGenerator()
generator = pagegenerators.PreloadingGenerator(basicgenerator)
for page in generator:
pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<"
% page.title())
if except_text_translated not in page.getImagePageHtml() and \
'http://' not in page.get():
pywikibot.output(u'\n' + page.title())
if template_image in page.get():
pywikibot.output(u"%s done already" % page.aslink())
continue
appendtext(page, u"\n\n"+template_image)
uploader = page.getFileVersionHistory().pop()[1]
usertalkname = u'User Talk:%s' % uploader
usertalkpage = pywikibot.Page(mysite, usertalkname)
msg2uploader = template_user % {'title': page.title()}
appendtext(usertalkpage, msg2uploader)
开发者ID:SASfit,项目名称:SASfit,代码行数:33,代码来源:unusedfiles.py
示例9: main
def main():
# If debug is True, don't edit pages, but only show what would have been
# changed.
debug = False
# The AfD log that should be treated.
date = None
# Whether to confirm edits.
always = False
# Parse command line arguments
for arg in wikipedia.handleArgs():
if arg.startswith('-debug'):
wikipedia.output(u'Debug mode.')
debug = True
elif arg.startswith('-date'):
if len(arg) == 5:
date = wikipedia.input(u'Please enter the date of the log that should be treated (yyyymmdd):')
else:
date = arg[6:]
elif arg.startswith('-always'):
always = True
if date:
page_title = u'Wikipedia:Te verwijderen pagina\'s/Toegevoegd %s' % date
else:
page_title = u'Wikipedia:Te verwijderen pagina\'s/Toegevoegd %s' % time.strftime("%Y%m%d", time.localtime(time.time()-60*60*24))
wikipedia.output(u'Checking: %s.' % page_title)
page = wikipedia.Page(wikipedia.getSite(code = 'nl', fam = 'wikipedia'), page_title)
bot = AfDBot(page, always, debug)
bot.run()
开发者ID:nlwikibots,项目名称:nlwikibots,代码行数:31,代码来源:tvpmelder.py
示例10: main
def main(args):
'''
Grab a bunch of images and tag them if they are not categorized.
'''
generator = None
genFactory = pagegenerators.GeneratorFactory()
site = pywikibot.getSite(u'commons', u'commons')
pywikibot.setSite(site)
for arg in pywikibot.handleArgs():
if arg.startswith('-yesterday'):
generator = uploadedYesterday(site)
elif arg.startswith('-recentchanges'):
generator = recentChanges(site=site, delay=120)
else:
genFactory.handleArg(arg)
if not generator:
generator = genFactory.getCombinedGenerator()
if not generator:
pywikibot.output(
u'You have to specify the generator you want to use for the program!')
else:
pregenerator = pagegenerators.PreloadingGenerator(generator)
for page in pregenerator:
if page.exists() and (page.namespace() == 6) \
and (not page.isRedirectPage()) :
if isUncat(page):
addUncat(page)
开发者ID:VisualEffects,项目名称:pywikia,代码行数:28,代码来源:imageuncat.py
示例11: 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()
开发者ID:Rodehi,项目名称:GFROS,代码行数:33,代码来源:image.py
示例12: main
def main(args):
"""
Main loop. Get a generator and options.
"""
generator = None
parent = u""
basename = u""
always = False
genFactory = pagegenerators.GeneratorFactory()
for arg in pywikibot.handleArgs():
if arg == "-always":
always = True
elif arg.startswith("-parent:"):
parent = arg[len("-parent:") :].strip()
elif arg.startswith("-basename"):
basename = arg[len("-basename:") :].strip()
else:
genFactory.handleArg(arg)
generator = genFactory.getCombinedGenerator()
if generator:
for page in generator:
createCategory(page, parent, basename)
else:
pywikibot.output(u"No pages to work on")
pywikibot.output(u"All done")
开发者ID:swertschak,项目名称:wikijournals-api,代码行数:29,代码来源:create_categories.py
示例13: main
def main():
global autonomous
global replace, replacealways, replaceloose, replaceonly
global use_hash
autonomous = False
replace = False
replacealways = False
replaceloose = False
replaceonly = False
use_hash = False
for arg in pywikibot.handleArgs():
if arg == '-autonomous':
autonomous = True
if arg == '-replace':
replace = True
if arg == '-replacealways':
replace = True
replacealways = True
if arg == '-replaceloose':
replaceloose = True
if arg == '-replaceonly':
replaceonly = True
if arg == '-hash':
use_hash = True
bot = NowCommonsDeleteBot()
bot.run()
开发者ID:Botomatik,项目名称:JackBot,代码行数:27,代码来源:nowcommons.py
示例14: main
def main():
wikipedia.setSite(wikipedia.getSite(u'commons', u'commons'))
bigcategory = u''
target = u''
generator = None
for arg in wikipedia.handleArgs():
if arg.startswith('-page'):
if len(arg) == 5:
generator = [wikipedia.Page(wikipedia.getSite(), wikipedia.input(u'What page do you want to use?'))]
else:
generator = [wikipedia.Page(wikipedia.getSite(), arg[6:])]
elif arg.startswith('-bigcat'):
if len(arg) == 7:
bigcategory = wikipedia.input(u'What category do you want to split out?')
else:
bigcategory = arg[8:]
elif arg.startswith('-target'):
if len(arg) == 7:
target = wikipedia.input(u'What category is the target category?')
else:
target = arg[8:]
if not bigcategory==u'':
splitOutCategory(bigcategory, target)
else:
if not generator:
generator = pagegenerators.NamespaceFilterPageGenerator(pagegenerators.ReferringPageGenerator(wikipedia.Page(wikipedia.getSite(), u'Template:Intersect categories'), onlyTemplateInclusion=True), [14])
for cat in generator:
intersectCategories(cat)
开发者ID:multichill,项目名称:toollabs,代码行数:31,代码来源:intersect_categories.py
示例15: main
def main():
'''
The main loop
'''
wikipedia.setSite(wikipedia.getSite(u'commons', u'commons'))
conn = None
cursor = None
(conn, cursor) = connectDatabase()
imagerecat.initLists()
generator = None;
genFactory = pagegenerators.GeneratorFactory()
mark = True
for arg in wikipedia.handleArgs():
if arg.startswith('-dontmark'):
mark = False
elif arg.startswith('-page'):
if len(arg) == 5:
generator = [wikipedia.Page(wikipedia.getSite(), wikipedia.input(u'What page do you want to use?'))]
else:
generator = [wikipedia.Page(wikipedia.getSite(), arg[6:])]
elif arg.startswith('-yesterday'):
generator = [wikipedia.Page(wikipedia.getSite(), u'Category:Media_needing_categories_as_of_' + getYesterday())]
else:
generator = genFactory.handleArg(arg)
if generator:
for page in generator:
if((page.namespace() == 14) and (page.title().startswith(u'Category:Media needing categories as of'))):
wikipedia.output(u'Working on ' + page.title())
for (image, gals, cats) in getImagesToCategorize(cursor, page.titleWithoutNamespace()):
categorizeImage(image, gals, imagerecat.applyAllFilters(cats))
if (mark):
categoriesChecked(page.title())
开发者ID:multichill,项目名称:toollabs,代码行数:35,代码来源:loose_category_from_gallery.py
示例16: main
def main():
wikipedia.setSite(wikipedia.getSite(u'commons', u'commons'))
# Connect database, we need that
conn = None
cursor = None
(conn, cursor) = connectDatabase()
generator = None
genFactory = pagegenerators.GeneratorFactory()
for arg in wikipedia.handleArgs():
genFactory.handleArg(arg)
generator = genFactory.getCombinedGenerator()
if not generator:
generator = getRijksmonumentWithoutLocation()
# Get a preloading generator with only images
pgenerator = pagegenerators.PreloadingGenerator(pagegenerators.NamespaceFilterPageGenerator(generator, [6]))
for page in pgenerator:
locationTemplate = locateImage(page, conn, cursor)
if locationTemplate:
addLocation(page, locationTemplate)
开发者ID:bymerej,项目名称:ts-multichill-bot,代码行数:25,代码来源:object_location_rijksmonumenten.py
示例17: main
def main():
doCount = False
argsList = []
namespaces = []
for arg in wikipedia.handleArgs():
if arg == '-count':
doCount = True
elif arg.startswith('-namespace:'):
try:
namespaces.append(int(arg[len('-namespace:'):]))
except ValueError:
namespaces.append(arg[len('-namespace:'):])
else:
argsList.append(arg)
if doCount:
robot = ReferencesRobot()
if not argsList:
argsList = templates
choice = ''
if 'reflist' in argsList:
wikipedia.output(u'NOTE: it will take a long time to count "reflist".')
choice = wikipedia.inputChoice(u'Proceed anyway?', ['yes', 'no', 'skip'], ['y', 'n', 's'], 'y')
if choice == 's':
argsList.remove('reflist')
if choice <> 'n':
robot.countRefs(argsList, namespaces)
else:
wikipedia.showHelp('refcheck')
开发者ID:VisualEffects,项目名称:pywikia,代码行数:29,代码来源:refcheck.py
示例18: main
def main(args):
'''
Main loop. Get a generator and options.
'''
generator = None
parent = u''
basename = u''
always = False
genFactory = pagegenerators.GeneratorFactory()
for arg in pywikibot.handleArgs():
if arg == '-always':
always = True
elif arg.startswith('-parent:'):
parent = arg [len('-parent:'):].strip()
elif arg.startswith('-basename'):
basename = arg [len('-basename:'):].strip()
else:
genFactory.handleArg(arg)
generator = genFactory.getCombinedGenerator()
if generator:
for page in generator:
createCategory(page, parent, basename)
else:
pywikibot.output(u'No pages to work on')
pywikibot.output(u'All done')
开发者ID:Botomatik,项目名称:JackBot,代码行数:29,代码来源:create_categories.py
示例19: main
def main():
genFactory = pagegenerators.GeneratorFactory()
commandline_arguments = list()
templateTitle = u''
for arg in pywikibot.handleArgs():
if arg.startswith('-template'):
if len(arg) == 9:
templateTitle = pywikibot.input(
u'Please enter the template to work on:')
else:
templateTitle = arg[10:]
elif genFactory.handleArg(arg):
continue
else:
commandline_arguments.append(arg)
if len(commandline_arguments) % 2 or not templateTitle:
raise ValueError # or something.
fields = dict()
for i in xrange (0, len(commandline_arguments), 2):
fields[commandline_arguments[i]] = commandline_arguments[i+1]
if templateTitle:
gen = pagegenerators.ReferringPageGenerator(pywikibot.Page(pywikibot.getSite(),"Template:%s" % templateTitle ), onlyTemplateInclusion = True)
else:
gen = genFactory.getCombinedGenerator()
if not gen:
# TODO: Build a transcluding generator based on templateTitle
return
bot = HarvestRobot(gen, templateTitle, fields)
bot.run()
开发者ID:pywikibot,项目名称:compat,代码行数:32,代码来源:harvest_template.py
示例20: main
def main():
global mysite, linktrail, page
start = []
for arg in wikipedia.handleArgs():
start.append(arg)
if start:
start = " ".join(start)
else:
start = "!"
mysite = wikipedia.getSite()
linktrail = mysite.linktrail()
try:
generator = pagegenerators.CategorizedPageGenerator(mysite.disambcategory(), start = start)
except wikipedia.NoPage:
print "The bot does not know the disambiguation category for your wiki."
raise
# only work on articles
generator = pagegenerators.NamespaceFilterPageGenerator(generator, [0])
generator = pagegenerators.PreloadingGenerator(generator)
pagestodo = []
pagestoload = []
for page in generator:
if page.isRedirectPage():
continue
linked = page.linkedPages()
pagestodo.append((page,linked))
pagestoload += linked
if len(pagestoload) > 49:
wikipedia.getall(mysite,pagestoload)
for page, links in pagestodo:
workon(page,links)
pagestoload = []
pagestodo = []
开发者ID:yknip1207,项目名称:genewiki,代码行数:33,代码来源:disambredir.py
注:本文中的wikipedia.handleArgs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论