本文整理汇总了Python中wikipedia.input函数的典型用法代码示例。如果您正苦于以下问题:Python input函数的具体用法?Python input怎么用?Python input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了input函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getReasonForDeletion
def getReasonForDeletion(self, page):
suggestedReason = self.guessReasonForDeletion(page)
pywikibot.output(u"The suggested reason is: \03{lightred}%s\03{default}" % suggestedReason)
# We don't use pywikibot.translate() here because for some languages the
# entry is intentionally left out.
if self.mySite.family.name in self.delete_reasons:
if page.site().lang in self.delete_reasons[self.mySite.family.name]:
localReasons = pywikibot.translate(page.site().lang, self.delete_reasons)
pywikibot.output(u"")
localReasoneKey = localReasons.keys()
localReasoneKey.sort()
for key in localReasoneKey:
pywikibot.output((key + ":").ljust(8) + localReasons[key])
pywikibot.output(u"")
reason = pywikibot.input(
u"Please enter the reason for deletion, choose a default reason, or press enter for the suggested message:"
)
if reason.strip() in localReasons:
reason = localReasons[reason]
else:
reason = pywikibot.input(
u"Please enter the reason for deletion, or press enter for the suggested message:"
)
else:
reason = pywikibot.input(u"Please enter the reason for deletion, or press enter for the suggested message:")
if not reason:
reason = suggestedReason
return reason
示例2: main
def main(args):
'''
Main loop.
'''
start_page = 0
end_page = 5
per = 100
for arg in wikipedia.handleArgs():
if arg.startswith('-start_page'):
if len(arg) == 11:
start_page = wikipedia.input(u'What is the id of the photo you want to start at?')
else:
start_page = arg[12:]
elif arg.startswith('-end_page'):
if len(arg) == 9:
end_page = wikipedia.input(u'What is the id of the photo you want to end at?')
else:
end_page = arg[10:]
elif arg.startswith('-per'):
if len(arg) == 4:
per = wikipedia.input(u'How much images per page?')
else:
per = arg[5:]
processGalleries(int(start_page), int(end_page), int(per))
示例3: 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)
示例4: main
def main():
bbox="20.2148438,43.7710938,29.7729492,48.1147666" #default to Romania
summary=None
lang=pywikibot.getSite().language()
# Loading the arguments
for arg in pywikibot.handleArgs():
if arg.startswith('-bbox'):
if len(arg) == 5:
bbox = pywikibot.input(
u'Please input the area to search for tagged nodes:')
else:
bbox = arg[6:]
elif arg.startswith('-summary'):
if len(arg) == 8:
summary = pywikibot.input(u'What summary do you want to use?')
else:
summary = arg[9:]
elif arg.startswith('-lang'):
if len(arg) == 5:
lang = pywikibot.input(u'What language do you want to use?')
else:
lang = arg[6:]
pages = getPageList(bbox, lang)
putCoordOnWiki(lang, pages)
示例5: main
def main(args):
'''
Main loop.
'''
start_id = 0
end_id = 45000
latest = False
for arg in wikipedia.handleArgs():
if arg.startswith('-start_id'):
if len(arg) == 9:
start_id = wikipedia.input(u'What is the id of the photo you want to start at?')
else:
start_id = arg[10:]
elif arg.startswith('-end_id'):
if len(arg) == 7:
end_id = wikipedia.input(u'What is the id of the photo you want to end at?')
else:
end_id = arg[8:]
elif arg==u'-latest':
latest = True
if latest:
processLatestPhotos()
else:
processPhotos(int(start_id), int(end_id))
示例6: main
def main():
lang=pywikibot.getSite().language()
start = None
# Loading the arguments
for arg in pywikibot.handleArgs():
if arg.startswith('-lang'):
if len(arg) == 5:
lang = pywikibot.input(u'What language do you want to use?')
else:
lang = arg[6:]
elif arg.startswith('-start'):
if len(arg) == 6:
start = pywikibot.input(u'What article do you want to start with?')
else:
start = arg[7:]
bot = o2wVillageData()
# bot.tl2Dict(bot.extractTemplate(u"""{{Infocaseta Așezare
# | nume = Bogdănești
# | alt_nume =
# | tip_asezare = Sat
# | imagine =
# | imagine_dimensiune = 250px
# | imagine_descriere = Bogdănești
# | stemă =
# | hartă =
# | pushpin_map =
# | pushpin_label_position = right
# | tip_subdiviziune = Țară
# | nume_subdiviziune = {{ROU}}
# | tip_subdiviziune1 = [[Județele României|Județ]]
# | nume_subdiviziune1 = [[județul Vaslui|Vaslui]]
# | tip_subdiviziune3 = [[Comunele României|Comună]]
# | nume_subdiviziune3 = [[Comuna Bogdănești, Vaslui|Bogdănești]]
# | titlu_atestare = Prima atestare
# | atestare =
# | suprafață_totală_km2 =
# | altitudine =
# | latd = 46
# | latm = 26
# | lats = 58
# | latNS = N
# | longd = 27
# | longm = 43
# | longs = 36
# | longEV = E
# | recensământ = 2002
# | populație =
# | populație_note_subsol =
# | tip_cod_poștal = [[Cod poștal]]
# | codpoștal =
# | camp_gol_nume =
# | camp_gol_info =
# }}
# '''Bogdănești''' este o localitate în [[județul Vaslui]], [[Moldova]], [[România]]
# """, u"Infocaseta Așezare"))
# print bot._dict
bot.putCoordOnWiki(lang, start)
示例7: askForCaptcha
def askForCaptcha(self, url):
try:
import webbrowser
wikipedia.output(u'Opening CAPTCHA in your web browser...')
webbrowser.open(url)
return wikipedia.input(u'What is the solution of the CAPTCHA that is shown in your web browser?')
except:
wikipedia.output(u'Error in opening web browser: %s' % sys.exc_info()[0])
return wikipedia.input(u'What is the solution of the CAPTCHA at %s ?' % url)
示例8: main
def main():
summary_commandline,template,gen = None,None,None
exceptions,PageTitles,namespaces = [],[],[]
cat=''
autoText,autoTitle = False,False
genFactory = pagegenerators.GeneratorFactory()
arg=False#------if you dont want to work with arguments leave it False if you want change it to True---
if arg==False:
for arg in wikipedia.handleArgs():
if arg == '-autotitle':
autoTitle = True
elif arg == '-autotext':
autoText = True
elif arg.startswith( '-page:' ):
if len(arg) == 6:
PageTitles.append(wikipedia.input( u'Which page do you want to chage?' ))
else:
PageTitles.append(arg[6:])
elif arg.startswith( '-cat:' ):
if len(arg) == 5:
cat=wikipedia.input( u'Which Category do you want to chage?' )
else:
cat='Category:'+arg[5:]
elif arg.startswith( '-template:' ):
if len(arg) == 10:
template.append(wikipedia.input( u'Which Template do you want to chage?' ))
else:
template.append('Template:'+arg[10:])
elif arg.startswith('-except:'):
exceptions.append(arg[8:])
elif arg.startswith( '-namespace:' ):
namespaces.append( int( arg[11:] ) )
elif arg.startswith( '-ns:' ):
namespaces.append( int( arg[4:] ) )
elif arg.startswith( '-summary:' ):
wikipedia.setAction( arg[9:] )
summary_commandline = True
else:
generator = genFactory.handleArg(arg)
if generator:
gen = generator
else:
PageTitles = [raw_input(u'Page:> ').decode('utf-8')]
if cat!='':
facatfalist=facatlist(cat)
if facatfalist!=False:
run(facatfalist)
if PageTitles:
pages = [wikipedia.Page(faSite,PageTitle) for PageTitle in PageTitles]
gen = iter( pages )
if not gen:
wikipedia.stopme()
sys.exit()
if namespaces != []:
gen = pagegenerators.NamespaceFilterPageGenerator( gen,namespaces )
preloadingGen = pagegenerators.PreloadingGenerator( gen,pageNumber = 60 )#---number of pages that you want load at same time
run(preloadingGen)
示例9: main
def main(args):
'''
Main loop.
'''
genFactory = pagegenerators.GeneratorFactory()
start_id = 0
end_id = 0
updaterun = False
site = wikipedia.getSite('commons', 'commons')
wikipedia.setSite(site)
updatePage = wikipedia.Page(site, u'User:BotMultichillT/Air_Force_latest')
interval=100
for arg in wikipedia.handleArgs():
if arg.startswith('-start_id'):
if len(arg) == 9:
start_id = wikipedia.input(u'What is the id of the photo you want to start at?')
else:
start_id = arg[10:]
elif arg.startswith('-end_id'):
if len(arg) == 7:
end_id = wikipedia.input(u'What is the id of the photo you want to end at?')
else:
end_id = arg[8:]
elif arg==u'-updaterun':
updaterun = True
elif arg.startswith('-interval'):
if len(arg) == 9:
interval = wikipedia.input(u'What interval do you want to use?')
else:
interval = arg[10:]
else:
genFactory.handleArg(arg)
generator = genFactory.getCombinedGenerator()
# Do we have a pagenerator?
if generator:
for page in generator:
if page.namespace()==14:
processCategory(page)
# Is updaterun set?
elif updaterun:
start_id = int(updatePage.get())
end_id = start_id + int(interval)
last_id = processPhotos(int(start_id), int(end_id))
comment = u'Worked from ' + str(start_id) + u' to ' + str(last_id)
updatePage.put(str(last_id), comment)
# Do we have a start_id and a end_id
elif int(start_id) > 0 and int(end_id) > 0:
last_id = processPhotos(int(start_id), int(end_id))
# Use the default generator
else:
print "Screw this, will implement later"
示例10: main
def main():
genFactory = pagegenerators.GeneratorFactory()
PageTitles = []
xmlFilename = None
always = False
ignorepdf = False
limit = None
namespaces = []
generator = None
for arg in pywikibot.handleArgs():
if arg.startswith('-namespace:'):
try:
namespaces.append(int(arg[11:]))
except ValueError:
namespaces.append(arg[11:])
elif arg.startswith('-summary:'):
pywikibot.setAction(arg[9:])
elif arg == '-always':
always = True
elif arg == '-ignorepdf':
ignorepdf= True
elif arg.startswith('-limit:'):
limit = int(arg[7:])
elif arg.startswith('-xmlstart'):
if len(arg) == 9:
xmlStart = pywikibot.input(
u'Please enter the dumped article to start with:')
else:
xmlStart = arg[10:]
elif arg.startswith('-xml'):
if len(arg) == 4:
xmlFilename = pywikibot.input(
u'Please enter the XML dump\'s filename:')
else:
xmlFilename = arg[5:]
else:
genFactory.handleArg(arg)
if xmlFilename:
try:
xmlStart
except NameError:
xmlStart = None
generator = XmlDumpPageGenerator(xmlFilename, xmlStart, namespaces)
if not generator:
generator = genFactory.getCombinedGenerator()
if not generator:
# syntax error, show help text from the top of this file
pywikibot.showHelp('reflinks')
return
generator = pagegenerators.PreloadingGenerator(generator, pageNumber = 50)
generator = pagegenerators.RedirectFilterPageGenerator(generator)
bot = ReferencesRobot(generator, always, limit, ignorepdf)
bot.run()
示例11: main
def main(page=None):
# if -file is not used, this temporary array is used to read the page title.
pageTitle = []
# start = pywikibot.input('where to start?')
# basicgenerator = pagegenerators.AllpagesPageGenerator('!', 6)
# gen = pagegenerators.PreloadingGenerator(basicgenerator)
gen = None
interwiki = False
keep_name = False
targetLang = None
targetFamily = None
for arg in pywikibot.handleArgs():
print arg
if arg == "-interwiki":
interwiki = True
elif arg.startswith("-keepname"):
keep_name = True
elif arg.startswith("-tolang:"):
targetLang = arg[8:]
elif arg.startswith("-tofamily:"):
targetFamily = arg[10:]
elif arg.startswith("-file"):
if len(arg) == 5:
filename = pywikibot.input(u"Please enter the list's filename: ")
else:
filename = arg[6:]
gen = pagegenerators.TextfilePageGenerator(filename)
else:
pageTitle.append(arg)
if not gen:
# if the page title is given as a command line argument,
# connect the title's parts with spaces
if pageTitle != []:
pageTitle = " ".join(pageTitle)
page = pywikibot.Page(pywikibot.getSite(), pageTitle)
# if no page title was given as an argument, and none was
# read from a file, query the user
if not page:
pageTitle = pywikibot.input(u"Which page to check:")
page = pywikibot.Page(pywikibot.getSite(), pageTitle)
# generator which will yield only a single Page
gen = iter([page])
if not targetLang and not targetFamily:
targetSite = pywikibot.getSite("commons", "commons")
else:
if not targetLang:
targetLang = None # pywikibot.getSite().language
if not targetFamily:
targetFamily = None # pywikibot.getSite().family
targetSite = pywikibot.getSite(targetLang, targetFamily)
bot = ImageTransferBot(gen, interwiki=interwiki, targetSite=targetSite, keep_name=keep_name)
bot.run()
示例12: main
def main():
start = '!'
featured = False
title = None
namespace = None
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 wikipedia.handleArgs():
if arg == '-featured':
featured = True
elif arg.startswith('-page'):
if len(arg) == 5:
title = wikipedia.input(u'Which page should be processed?')
else:
title = arg[6:]
elif arg.startswith('-namespace'):
if len(arg) == 10:
namespace = int(wikipedia.input(u'Which namespace should be processed?'))
else:
namespace = int(arg[11:])
else:
genFactory.handleArg(arg)
gen = genFactory.getCombinedGenerator()
mysite = wikipedia.getSite()
if mysite.sitename() == 'wikipedia:nl':
wikipedia.output(u'\03{lightred}There is consensus on the Dutch Wikipedia that bots should not be used to fix redirects.\03{default}')
sys.exit()
linktrail = mysite.linktrail()
if featured:
featuredList = wikipedia.translate(mysite, featured_articles)
ref = wikipedia.Page(wikipedia.getSite(), featuredList)
gen = pagegenerators.ReferringPageGenerator(ref)
generator = pagegenerators.NamespaceFilterPageGenerator(gen, [0])
for page in generator:
workon(page)
elif title is not None:
page = wikipedia.Page(wikipedia.getSite(), title)
workon(page)
elif namespace is not None:
for page in pagegenerators.AllpagesPageGenerator(start=start, namespace=namespace, includeredirects=False):
workon(page)
elif gen:
for page in pagegenerators.PreloadingGenerator(gen):
workon(page)
else:
wikipedia.showHelp('fixing_redirects')
示例13: main
def main():
# if -file is not used, this temporary array is used to read the page title.
pageTitle = []
page = None
gen = None
interwiki = False
keep_name = False
targetLang = None
targetFamily = None
for arg in pywikibot.handleArgs():
if arg == '-interwiki':
interwiki = True
elif arg.startswith('-keepname'):
keep_name = True
elif arg.startswith('-tolang:'):
targetLang = arg[8:]
elif arg.startswith('-tofamily:'):
targetFamily = arg[10:]
elif arg.startswith('-file'):
if len(arg) == 5:
filename = pywikibot.input(
u'Please enter the list\'s filename: ')
else:
filename = arg[6:]
gen = pagegenerators.TextfilePageGenerator(filename)
else:
pageTitle.append(arg)
if not gen:
# if the page title is given as a command line argument,
# connect the title's parts with spaces
if pageTitle != []:
pageTitle = ' '.join(pageTitle)
page = pywikibot.Page(pywikibot.getSite(), pageTitle)
# if no page title was given as an argument, and none was
# read from a file, query the user
if not page:
pageTitle = pywikibot.input(u'Which page to check:')
page = pywikibot.Page(pywikibot.getSite(), pageTitle)
# generator which will yield only a single Page
gen = iter([page])
if not targetLang and not targetFamily:
targetSite = pywikibot.getSite('commons', 'commons')
else:
if not targetLang:
targetLang = pywikibot.getSite().language
if not targetFamily:
targetFamily = pywikibot.getSite().family
targetSite = pywikibot.Site(targetLang, targetFamily)
bot = ImageTransferBot(gen, interwiki=interwiki, targetSite=targetSite,
keep_name=keep_name)
bot.run()
示例14: main
def main():
pywikibot.warning(u"This script will set preferences on all " u"configured accounts!")
pywikibot.output(
u"You have %s accounts configured." % sum([len(family) for family in config.usernames.itervalues()])
)
if pywikibot.inputChoice(u"Do you wish to continue?", ["no", "yes"], ["n", "y"], "n") == "n":
return
if (
pywikibot.inputChoice(
u"Do you already know which preference you wish " u"to set?", ["no", "yes"], ["n", "y"], "y"
)
== "n"
):
site = pywikibot.getSite()
pywikibot.output(u"Getting list of available preferences from %s." % site)
prefs = Preferences(site)
pywikibot.output(u"-" * 73)
pywikibot.output(u"| Name | Value |")
pywikibot.output(u"-" * 73)
pref_data = prefs.items()
pref_data.sort()
for key, value in pref_data:
pywikibot.output(table_cell(key, 4) + table_cell(value, 5) + "|")
pywikibot.output(u"-" * 73)
pywikibot.output(u"")
pywikibot.output(u"(For checkboxes: An empty string evaluates to False; " u"all others to True)")
pywikibot.output(u"")
while True:
keys, values = [], []
while True:
try:
keys.append(pywikibot.input(u"Which preference do you wish to set?"))
except KeyboardInterrupt:
return
values.append(pywikibot.input(u"To what value do you wish to set '%s'?" % keys[-1]))
if pywikibot.inputChoice(u"Set more preferences?", ["no", "yes"], ["n", "y"], "n") == "n":
break
if (
pywikibot.inputChoice(
u"Set %s?" % u", ".join(u"%s:%s" % (key, value) for key, value in zip(keys, values)),
["yes", "no"],
["y", "n"],
"n",
)
== "y"
):
set_all(keys, values, verbose=True)
pywikibot.output(u"Preferences have been set on all wikis.")
示例15: main
def main():
pywikibot.warning(u'This script will set preferences on all '
u'configured accounts!')
pywikibot.output(u'You have %s accounts configured.'
% sum([len(family)
for family in config.usernames.itervalues()]))
if pywikibot.inputChoice(u'Do you wish to continue?',
['no', 'yes'], ['n', 'y'], 'n') == 'n':
return
if pywikibot.inputChoice(u'Do you already know which preference you wish '
u'to set?', ['no', 'yes'], ['n', 'y'], 'y') == 'n':
site = pywikibot.getSite()
pywikibot.output(u'Getting list of available preferences from %s.'
% site)
prefs = Preferences(site)
pywikibot.output(u'-' * 73)
pywikibot.output(u'| Name | Value |')
pywikibot.output(u'-' * 73)
pref_data = prefs.items()
pref_data.sort()
for key, value in pref_data:
pywikibot.output(table_cell(key, 4) + table_cell(value, 5) + '|')
pywikibot.output(u'-' * 73)
pywikibot.output(u'')
pywikibot.output(u'(For checkboxes: An empty string evaluates to False; '
u'all others to True)')
pywikibot.output(u'')
while True:
keys, values = [], []
while True:
try:
keys.append(pywikibot.input(
u'Which preference do you wish to set?'))
except KeyboardInterrupt:
return
values.append(pywikibot.input(
u"To what value do you wish to set '%s'?" % keys[-1]))
if pywikibot.inputChoice(u"Set more preferences?",
['no', 'yes'], ['n', 'y'], 'n') == 'n':
break
if pywikibot.inputChoice(
u"Set %s?"
% u', '.join(u'%s:%s' % (key, value)
for key, value in zip(keys, values)),
['yes', 'no'], ['y', 'n'], 'n') == 'y':
set_all(keys, values, verbose=True)
pywikibot.output(u"Preferences have been set on all wikis.")