• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python wikipedia.input函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wikipedia.input函数的典型用法代码示例。如果您正苦于以下问题:Python input函数的具体用法?Python input怎么用?Python input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了input函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:valhallasw,项目名称:pwb-test-alpha,代码行数:30,代码来源:speedy_delete.py


示例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))
开发者ID:bymerej,项目名称:ts-multichill-bot,代码行数:25,代码来源:army_bot.py


示例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)
开发者ID:multichill,项目名称:toollabs,代码行数:31,代码来源:intersect_categories.py


示例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)
开发者ID:edgarskos,项目名称:wikiro,代码行数:25,代码来源:osm2wiki_coord.py


示例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))
开发者ID:bymerej,项目名称:ts-multichill-bot,代码行数:25,代码来源:fema_bot.py


示例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)
开发者ID:edgarskos,项目名称:wikiro,代码行数:59,代码来源:osm2wiki_template.py


示例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)
开发者ID:carriercomm,项目名称:sicekit,代码行数:9,代码来源:terminal_interface.py


示例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)
开发者ID:PersianWikipedia,项目名称:fawikibot,代码行数:57,代码来源:zzgallery.py


示例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"
开发者ID:multichill,项目名称:toollabs,代码行数:56,代码来源:air_force_bot.py


示例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()
开发者ID:edgarskos,项目名称:pywikipedia-git,代码行数:55,代码来源:reflinks.py


示例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()
开发者ID:Brickimedia,项目名称:generalscripts,代码行数:55,代码来源:imagetransfer.py


示例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')
开发者ID:pyropeter,项目名称:PyroBot-1G,代码行数:54,代码来源:fixing_redirects.py


示例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()
开发者ID:NaturalSolutions,项目名称:ecoReleve-Concepts,代码行数:54,代码来源:imagetransfer.py


示例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.")
开发者ID:NaturalSolutions,项目名称:ecoReleve-Concepts,代码行数:54,代码来源:preferences.py


示例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.")
开发者ID:pywikibot,项目名称:compat,代码行数:53,代码来源:preferences.py


示例16: main

def main(args):
    """
    Main loop.
    """
    start_id = 0
    end_id = 80000
    single_id = 0
    latest = False
    updaterun = False
    site = wikipedia.getSite("commons", "commons")
    updatePage = wikipedia.Page(site, u"User:BotMultichillT/Navy_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.startswith("-id"):
            if len(arg) == 3:
                single_id = wikipedia.input(u"What is the id of the photo you want to transfer?")
            else:
                single_id = arg[4:]
        elif arg == u"-latest":
            latest = True
        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:]

    if single_id > 0:
        processPhoto(photo_id=int(single_id))
    elif latest:
        processLatestPhotos()
    else:
        if updaterun:
            start_id = int(updatePage.get())
            end_id = start_id + int(interval)

        last_id = processPhotos(int(start_id), int(end_id))

        if updaterun:
            comment = u"Worked from " + str(start_id) + u" to " + str(last_id)
            updatePage.put(str(last_id), comment)
开发者ID:bymerej,项目名称:ts-multichill-bot,代码行数:53,代码来源:navy_bot.py


示例17: askForCaptcha

 def askForCaptcha(self, url):
     try:
         import webbrowser
         wikipedia.output(u'Opening CAPTCHA in your web browser...')
         if webbrowser.open(url):
             return wikipedia.input(u'What is the solution of the CAPTCHA that is shown in your web browser?')
         else:
             raise
     except:
         wikipedia.output(u'Error in opening web browser: %s' % sys.exc_info()[0])
         wikipedia.output(u'Please copy this url to your web browser and open it:\n %s' % url)
         return wikipedia.input(u'What is the solution of the CAPTCHA at this url ?')
开发者ID:valhallasw,项目名称:pwb-test-alpha,代码行数:12,代码来源:terminal_interface_base.py


示例18: addCoords

def addCoords(sourceWiki, lang, article, lat, lon, region, type, dim):
    '''
    Add the coordinates to article.
    '''

    if (article and lang and type):
        coordTemplate = 'Coordinate'
        site = wikipedia.getSite(lang, 'wikipedia')

        page = wikipedia.Page(site, article)
        try:
            text = page.get()
        except wikipedia.NoPage: # First except, prevent empty pages
            logging.warning('Page empty: %s', article)
            return False
        except wikipedia.IsRedirectPage: # second except, prevent redirect
            logging.warning('Page is redirect: %s', article)
            wikipedia.output(u'%s is a redirect!' % article)
            return False
        except wikipedia.Error: # third exception, take the problem and print
            logging.warning('Some error: %s', article)
            wikipedia.output(u"Some error, skipping..")
            return False       
    
        if coordTemplate in page.templates():
            logging.info('Already has Coordinate template: %s', article)
            return False

        if 'Linn' in page.templates():
            logging.info('Linn template without coords: %s', article)
            return False
            
        newtext = text
        replCount = 1
        coordText = u'{{Coordinate |NS=%s |EW=%s |type=%s |region=%s' % (lat, lon, type, region)
        if (dim):
            coordText += u' |dim=%s' % ( int(dim),)
        coordText += '}}'
        localCatName = wikipedia.getSite().namespace(WP_CATEGORY_NS)
        catStart = r'\[\[(' + localCatName + '|Category):'
        catStartPlain = u'[[' + localCatName + ':'
        replacementText = u''
        replacementText = coordText + '\n\n' + catStartPlain
    
        # insert coordinate template before categories
        newtext = re.sub(catStart, replacementText, newtext, replCount, flags=re.IGNORECASE)

        if text != newtext:
            logging.info('Adding coords to: %s', article)
            comment = u'lisan artikli koordinaadid %s.wikist' % (sourceWiki)
            wikipedia.showDiff(text, newtext)
            modPage = wikipedia.input(u'Modify page: %s ([y]/n) ?' % (article) )
            if (modPage.lower == 'y' or modPage == ''):
                page.put(newtext, comment)
            return True
        else:
            logging.info('Nothing to change: %s', article)
            return False
    else:
        return False
开发者ID:edgarskos,项目名称:Toolserver-bots,代码行数:60,代码来源:coord_to_articles.py


示例19: 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


示例20: TextfilePageGenerator

def TextfilePageGenerator(filename=None, site=None):
    """Iterate pages from a list in a text file.

    The file must contain page links between double-square-brackets or, in
    alternative, separated by newlines, and return them as a list of Page
    objects. The generator will yield each corresponding Page object.

    @param filename: the name of the file that should be read. If no name is
                     given, the generator prompts the user.
    @param site: the default Site for which Page objects should be created

    """
    if filename is None:
        filename = pywikibot.input(u'Please enter the filename:')
    if site is None:
        site = pywikibot.getSite()
    f = codecs.open(filename, 'r', config.textfile_encoding)
    R = re.compile(ur'\[\[(.+?)(?:\]\]|\|)') # title ends either before | or before ]]
    pageTitle = None
    for pageTitle in R.findall(f.read()):
        # If the link doesn't refer to this site, the Page constructor
        # will automatically choose the correct site.
        # This makes it possible to work on different wikis using a single
        # text file, but also could be dangerous because you might
        # inadvertently change pages on another wiki!
        yield pywikibot.Page(site, pageTitle)
    if pageTitle is None:
        f.seek(0)
        for title in f:
            title = title.strip()
            if '|' in title:
                title = title[:title.index('|')]
            if title:
                yield pywikibot.Page(site, title)
    f.close()
开发者ID:dbow,项目名称:Project-OPEN,代码行数:35,代码来源:pagegenerators.py



注:本文中的wikipedia.input函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python wikipedia.inputChoice函数代码示例发布时间:2022-05-26
下一篇:
Python wikipedia.handleArgs函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap