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

Python wikipedia.stopme函数代码示例

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

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



在下文中一共展示了stopme函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: abort

	def abort(self, status = u'Ok', msg = None):
		log = u'Bot aborted with status: '+status
		if msg:
			log += u' and message: '+msg
		self.log(log)
		wikipedia.stopme()
		exit(1)
开发者ID:VisualEffects,项目名称:pywikia,代码行数:7,代码来源:GESync.py


示例2: checktalk

def checktalk():
	site = wikipedia.getSite()
	path = site.put_address('Non-existing_page')
	text = site.getUrl(path)
	if '<div class="usermessage">' in text:
		wikipedia.output(u'NOTE: You have unread messages on %s' % site)
		wikipedia.stopme()
		sys.exit()
开发者ID:edgarskos,项目名称:legobot-old,代码行数:8,代码来源:WPTagFilm.py


示例3: Import

 def Import(self, target, project = 'w', crono = '1', namespace = '', prompt = True):
     """Import the page from the wiki. Requires administrator status.
     If prompt is True, asks the user if he wants to delete the page.
     """
     # Fixing the crono value...
     if crono == True:
         crono = '1'
     elif crono == False:
         crono = '0'
     elif crono == '0':
         pass
     elif crono == '1':
         pass
     else:
         wikipedia.output(u'Crono value set wrongly.')
         wikipedia.stopme()
     # Fixing namespace's value.
     if namespace == '0':
         namespace == ''        
     answer = 'y'
     if prompt:
         answer = wikipedia.inputChoice(u'Do you want to import %s?' % target, ['Yes', 'No'], ['y', 'N'], 'N')
     if answer in ['y', 'Y']:
         host = self.site().hostname()
         address = '/w/index.php?title=%s&action=submit' % self.urlname()
         # You need to be a sysop for the import.
         self.site().forceLogin(sysop = True)
         # Getting the token.
         token = self.site().getToken(self, sysop = True)
         # Defing the predata.
         predata = {
             'action' : 'submit',
             'source' : 'interwiki',
             # from what project do you want to import the page?
             'interwiki' : project,
             # What is the page that you want to import?
             'frompage' : target,
             # The entire history... or not?
             'interwikiHistory' : crono,
             # What namespace do you want?
             'namespace': '',
         }
         if self.site().hostname() in config.authenticate.keys():
             predata['Content-type'] = 'application/x-www-form-urlencoded'
             predata['User-agent'] = useragent
             data = self.site().urlEncode(predata)
             response = urllib2.urlopen(urllib2.Request('http://' + self.site().hostname() + address, data))
             data = u''
         else:
             response, data = self.site().postForm(address, predata, sysop = True)
         if data:
             wikipedia.output(u'Page imported, checking...')
             if wikipedia.Page(site, target).exists():
                 wikipedia.output(u'Import success!')
                 return True
             else:
                 wikipedia.output(u'Import failed!')
                 return False
开发者ID:yknip1207,项目名称:genewiki,代码行数:58,代码来源:import.py


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


示例5: main

def main():
    site = pywikibot.getSite('en', 'wikipedia')
    prefix = 'Uw-'
    ns = 10

    for p in site.prefixindex(prefix, namespace=ns):
        print p.title()

    pywikibot.stopme()
开发者ID:whym,项目名称:RevDiffSearch,代码行数:9,代码来源:prefixed_titles.py


示例6: delTestPage

def delTestPage(pagename):
	myuserpage = u"ഉപയോക്താവ്:" + 'Manubot'
	mypage = myuserpage + "/BotLabs/test" + pagename
	 
	 
	# doing the job
	site = wikipedia.getSite('ml','wikipedia')
	page = wikipedia.Page(site,mypage)
	page.delete(reason='Deleting Test pages', prompt=False, throttle=True, mark=True)	
	wikipedia.stopme()	
开发者ID:paritystack,项目名称:wiki,代码行数:10,代码来源:manubot.py


示例7: shutoffcheck

 def shutoffcheck(self):
     return # Not implemented
     print u'Checking emergency shutoff page %s.' % self.shutoffpage.title(asLink=True)
     self.shutoffpagetext = self.shutoffpage.get()
     if unicode(self.shutoffpagetext.strip()) != u'enable':
         print u'Emergency shutoff enabled; stopping.'
         pywikibot.stopme()
         exit()
     else:
         print u'Emergency shutoff disabled; continuing.'
开发者ID:HazardSJ,项目名称:commonswiki,代码行数:10,代码来源:sandbot.py


示例8: shutoffcheck

def shutoffcheck():
	site = wikipedia.getSite()
	pagename = "User:Hazard-Bot/Check/Wikiproject"
	page = wikipedia.Page(site, pagename)
	print "Checking [[" + pagename + "]]for emergency shutoff."
	text = page.get()
	if text.lower() != 'enable':
		print "Emergency shutoff enabled; stopping."
		wikipedia.stopme()
		exit()
	print "Emergency shutoff disabled; continuing."
开发者ID:HazardSJ,项目名称:enwiki,代码行数:11,代码来源:wikiproject.py


示例9: udate2wiki

def udate2wiki(pagename=u'ഉപയോക്താവ്:Manubot/sandbox',towiki=True):
	global gpageData
	if towiki:
		site = wikipedia.getSite('ml','wikipedia')
		page = wikipedia.Page(site,pagename)
		page.put(gpageData,u'ബോട്ടിന്റെ കൂന്തി വിളയാട്ടം')		
		wikipedia.stopme()
	else:
		f = codecs.open(pagename+u'.txt',encoding='utf-8', mode='w')
		f.write(gpageData)
		f.close()	
开发者ID:paritystack,项目名称:wiki,代码行数:11,代码来源:manubot.py


示例10: main

def main(*args):
    global bot
    try:
        a = pywikibot.handleArgs(*args)
        if len(a) == 1:
            raise RuntimeError('Unrecognized argument "%s"' % a[0])
        elif a:
            raise RuntimeError("Unrecognized arguments: " + " ".join(('"%s"' % arg) for arg in a))
        bot = CategoryRedirectBot()
        bot.run()
    finally:
        pywikibot.stopme()
开发者ID:NaturalSolutions,项目名称:ecoReleve-Concepts,代码行数:12,代码来源:category_redirect.py


示例11: main

def main():
    summary_commandline,gen,template = None,None,None
    namespaces,PageTitles,exceptions = [],[],[]    
    encat=''
    autoText,autoTitle = False,False
    recentcat,newcat=False,False
    genFactory = pagegenerators.GeneratorFactory()
    for arg in wikipedia.handleArgs():
        if arg == '-autotitle':
            autoTitle = True
        elif arg == '-autotext':
            autoText = True
        elif arg.startswith( '-except:' ):
            exceptions.append( arg[8:] )
            
        elif arg.startswith('-start'):
            firstPageTitle = arg[7:]
            if not firstPageTitle:
                firstPageTitle = wikipedia.input(
                    u'At which page do you want to start?')
            firstPageTitle = wikipedia.Page(fasite,firstPageTitle).title(withNamespace=False)
            gen = pagegenerators.AllpagesPageGenerator(firstPageTitle, 0,
                                        includeredirects=True)    
        elif arg.startswith( '-template:' ):
            template = arg[10:]
        elif arg.startswith( '-namespace:' ):
            namespaces.append( int( arg[11:] ) )
        elif arg.startswith( '-summary:' ):
            wikipedia.setAction( arg[9:] )
            summary_commandline = True
        else:
            generator = genFactory.handleArg( arg )
            if generator:
                gen = generator
    if not gen:
        wikipedia.stopme()
        sys.exit()
    if namespaces != []:
        gen = pagegenerators.PreloadingGenerator(gen,pageNumber = 60)    
        preloadingGen = pagegenerators.NamespaceFilterPageGenerator( gen,namespaces )
    else:
         preloadingGen = pagegenerators.PreloadingGenerator(gen,pageNumber = 60)
    _cache,last_timestamp=get_cache()
    add_text(preloadingGen)

    now = str(datetime.now())
    todaynum=int(now.split('-')[2].split(' ')[0])+int(now.split('-')[1])*30+(int(now.split('-')[0])-2000)*365

    if last_timestamp+3 < todaynum:
        put_cache(_cache,todaynum)
    else:
        put_cache({},0)
开发者ID:PersianWikipedia,项目名称:fawikibot,代码行数:52,代码来源:zzredirectyeh.py


示例12: post

def post(unlock = True):
    """
    This function removes throttle file. It also removes lockfile unless
    unlock variable is set to False
    """
    if unlock and lockfile:
        try:
            os.remove(lockfile)
        except OSError:
            error(u"Unable to remove lockfile.")

    pywikibot.output(u"The script " + fullname + u". Stop at " + getTime())
    pywikibot.stopme()
    sys.exit()
开发者ID:nullzero,项目名称:wp,代码行数:14,代码来源:preload.py


示例13: getInfobox

def getInfobox(film):
	info_box_data = []
	if type(film).__name__ == 'str' or type(film).__name__ == 'unicode':
		site = wikipedia.getSite('en','wikipedia') # Taking the default site
		page = wikipedia.Page(site, film) # Calling the constructor
		if page.isRedirectPage():
			page = page.getRedirectTarget()	
	else:
		page = film
	page_data = page.get()
	#print page_data
	page_data = page_data.split(u'\n')
	info_box = 0
	#remove the |
	r = re.compile(r'^\s*\|\s*',re.UNICODE)

	info_re = re.compile(r'\s*{{\s*Infobox\s*film\s*',re.IGNORECASE|re.UNICODE)
	#remove spaces
	r1 = re.compile(r'\s*=\s*',re.UNICODE)
	#remove comments
	#r2 = re.compile(r'<!--.*-->')


	#Get the info box data
	for line in page_data:
		if len(line) == 0:
			continue
		if info_re.search(line) and info_box == 0:
			print 'Found infobox'
			info_box = 1
		elif line == u'}}' or line == u'|}}' and info_box ==1:
			info_box = 0
			break
		elif info_box == 1:
		#remove unnecessary data
			line = r.sub('',line)
			#line = r2.sub('',line) 
			line = r1.sub('=',line)
			print line
			info_box_data.append(line)
		else:
			pass

	#update in dictionary 
	for i in info_box_data:
		info_box_dict[i.split(u'=',1)[0].strip()] = i.split(u'=',1)[1].strip()
			
	#print info_box_data
	#print info_box_dict
	wikipedia.stopme()
开发者ID:paritystack,项目名称:wiki,代码行数:50,代码来源:wiki_bot.py


示例14: udate2wiki

def udate2wiki(pagename=u'',towiki=True):
	global data
	if towiki:
		myuserpage = u"ഉപയോക്താവ്:" + 'Manubot'
		mypage = myuserpage + "/BotLabs/" + (pagename)
		 
		# doing the job
		site = wikipedia.getSite('ml','wikipedia')
		page = wikipedia.Page(site,mypage)
		page.put(data,u'ബോട്ടിന്റെ കൂന്തി വിളയാട്ടം')		
		wikipedia.stopme()
	else:
		f = codecs.open(pagename+u'.txt',encoding='utf-8', mode='w')
		f.write(data)
		f.close()
开发者ID:paritystack,项目名称:wiki,代码行数:15,代码来源:wiki_bot.py


示例15: main

def main(*args):
    try:
        genFactory = GeneratorFactory()
        for arg in pywikibot.handleArgs():
            if not genFactory.handleArg(arg):
                pywikibot.showHelp('pagegenerators')
                break
        else:
            gen = genFactory.getCombinedGenerator()
            if gen:
                i = 0
                for page in gen:
                    i+=1
                    pywikibot.output("%4d: %s" % (i, page.title()), toStdout = True)
            else:
                pywikibot.showHelp('pagegenerators')
    finally:
        pywikibot.stopme()
开发者ID:dbow,项目名称:Project-OPEN,代码行数:18,代码来源:pagegenerators.py


示例16: main

def main(*args):
    try:
        list_page = pywikibot.Page(pywikibot.getSite(),
            'User:Petrb/Weird pages'
        )
        page_text = list_page.get()
        lines = page_text.split('\n')
        list_elems = lines[1:-2]
        summary = u"[[User:HasteurBot|HasteurBot Task 5]]: Adding maint " +\
            u"category to identified page"
        page_match = re.compile('\{\{AFC submission\|')
        page_match2 = re.compile('\{\{AfC submission\|')
        cat_match = re.compile('\[\[Category\:AfC submissions with missing AfC template\]\]')
        limiter = 50 - 14
        for elem in list_elems:
            if excluded_page(elem):
                continue
            ind_page = pywikibot.Page(pywikibot.getSite(),
                u'Wikipedia talk:'+elem
            )
            if not ind_page.exists():
                continue
            if ind_page.isRedirectPage():
                ind_page = ind_page.getRedirectTarget()
            if ind_page.namespace() != 5:
                continue
            page_text = ind_page.get()
            if page_match.match(page_text) is None \
                and \
                page_match2.match(page_text) is None \
                and \
                'AfC_submissions_with_missing_AfC_template' not in page_text \
                and \
                'AfC submissions with missing AfC template' not in page_text:
                limiter = limiter - 1
                print elem
                imp_text = page_text + \
                    '\n[[Category:AfC submissions with missing AfC template]]'
                ind_page.put(imp_text, comment=summary)
            if limiter == 0:
                break

    finally:
        pywikibot.stopme()
开发者ID:hasteur,项目名称:hasteurbot_task_3,代码行数:44,代码来源:add_magic_cat.py


示例17: main

def main():
	gen = None
	PageTitles = []
	
	# Read commandline parameters.
	for arg in wikipedia.handleArgs():
    	if arg.startswith('-page'):
            if len(arg) == 5:
				PageTitles.append(wikipedia.input(u'Which page do you want to change?'))
			else:
				PageTitles.append(arg[6:])
	
	PageTitles

if __name__ == "__main__":
	try:
		main()
	finally:
		wikipedia.stopme()
开发者ID:VisualEffects,项目名称:pywikia,代码行数:19,代码来源:anime-sync.py


示例18: log

	def log(self, msg = u''):
		self.setLogHeader()
		text = None
		try:
			text = self.logPage.get(force=True)
		except wikipedia.NoPage:
			print "ERROR: No log page found."
			wikipedia.stopme()
			exit(1)
		loc = text.find(self.header)
		if loc == -1:
			print "ERROR: No header found on log page."
			wikipedia.stopme()
			exit(1)
		loc += len(self.header)+1
		log = '\n'+strftime(u'%H:%M:%S - ')+msg+u'<br />'
		text = text[0:loc] + log + text[loc:]
		print "logging: "+log[1:len(log)]
		self.logPage.put(text)
开发者ID:VisualEffects,项目名称:pywikia,代码行数:19,代码来源:GESync.py


示例19: main

def main():
    global CD
    output(u'Running ' + __version__)
    CD = CommonsDelinker()
    output(u'This bot runs from: ' + str(CD.site))

    re._MAXCACHE = 4

    args = wikipedia.handleArgs()
    if '-since' in args:
        # NOTE: Untested
        ts_format = '%Y-%m-%d %H:%M:%S'
        try:
            since = time.strptime(
                args[args.index('-since') + 1],
                ts_format)
        except ValueError:
            if args[args.index('-since') + 1][0] == '[' and \
                    len(args) != args.index('-since') + 2:
                since = time.strptime('%s %s' % \
                    args[args.index('-since') + 1],
                    '[%s]' % ts_format)
            else:
                raise ValueError('Incorrect time format!')
        output(u'Reading deletion log since [%s]' %\
            time.strftime(ts_format, since))
        CD.last_check = time.mktime(since)

    try:
        try:
            CD.start()
        except Exception, e:
            if type(e) not in (SystemExit, KeyboardInterrupt):
                output('An exception occured in the main thread!', False)
                traceback.print_exc(file = sys.stderr)
                threadpool.terminate()
    finally:
        output(u'Stopping CommonsDelinker')
        wikipedia.stopme()
        # Flush the standard streams
        sys.stdout.flush()
        sys.stderr.flush()
开发者ID:legoktm,项目名称:pywikipedia-original,代码行数:42,代码来源:delinker.py


示例20: main

def main():    
    gen = None
    genFactory = pagegenerators.GeneratorFactory()    
    for arg in wikipedia.handleArgs():
        if arg.startswith('-newtem'):    
            arg=arg.replace(':','')
            if len(arg) == 7:
                genfa = pagegenerators.NewpagesPageGenerator(100, False, None,10)
            else:
                genfa = pagegenerators.NewpagesPageGenerator(int(arg[8:]), False, None,10)
            gen = pagegenerators.PreloadingGenerator( genfa,60)
        else:
            gen = genFactory.handleArg( arg )    
 
    if not gen:
        wikipedia.stopme()
        sys.exit()
    preloadingGen = pagegenerators.PreloadingGenerator(gen,pageNumber = 60)    
    #preloadingGen = pagegenerators.NamespaceFilterPageGenerator(gen,10)
    add_nav(preloadingGen)
开发者ID:PersianWikipedia,项目名称:fawikibot,代码行数:20,代码来源:zzaddnavebox.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python wikipedia.summary函数代码示例发布时间:2022-05-26
下一篇:
Python wikipedia.showHelp函数代码示例发布时间: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