示例#1
0
def main():
	check_page()
	log('Run started')
	cat = mwclient.listing.Category(site, 'CATEGORY') # Category:Companies based in California
	print "Getting category contents..."
	pages = bot.listpages(cat,names=False)
	for page in pages:
		if page.namespace == 0:
			if page.name not in skip_these and not title_blacklist_regex.search(page.name):
				if page.exists:
					if not page.redirect:
						talk_page = site.Pages['Talk:'+page.name]
						text = talk_page.edit()
						if not template_skip_regex.search(text):
							newtext = '{{COI editnotice|track=yes}}\n' + text
							try:
								check_page()
								talk_page.save(newtext, summary="[[WP:BOT|Bot]] on trial: Added [[Template:COI editnotice]] to [[%s]]) ([[User:Theo's Little Bot/disable/talkpage|disable]]" % page.name, minor=True)
								log('Saved edit on [[%s]]' % talk_page.name)
							except:
								log('Skipping %s because of unknown error' % talk_page.name)
						else:
							log('[[%s]] ignored due to regular expression' % talk_page.name)
					else:
						log('Page %s is a redirect; skipping.' % page.name)
				else:
					log('Page %s does not exist; skipping.' % page.name)
			else:
				log('Page %s was in skip list.' % page.name)
		else:
			log('Page %s is not in the article namespace.' % page.name)
	shut_down()
示例#2
0
文件: banners.py 项目: 930913/theobot
def main():
    site = mwclient.Site("en.wikipedia.org")
    site.login(password.username, password.password)

    templates = {}
    cat = mwclient.listing.Category(site, "Category:WikiProject banners with quality assessment")
    for template in bot.listpages(cat, names=False, includeredirects=False):
        if template.page_title.find("/testcases") == -1 and template.page_title.find("/sandbox") == -1:
            print "working on {}".format(template.page_title)
            templates[get_project(template) or template.page_title] = template.page_title
        else:
            pass

    output = json.dumps(templates, sort_keys=True, indent=4, separators=(",", ": "))

    outputpage = site.Pages["User:Theo's Little Bot/afchwikiproject.js"]
    outputpage.save(output, summary="[[WP:BOT|Bot]]: Updating WikiProject index for [[WP:AFCH|]]")
示例#3
0
def main():
	global site
	site = mwclient.Site('en.wikipedia.org')
	site.login(password.username, password.password)

	category = mwclient.listing.Category(site, 'Category:Minor planets')
	results = []
	for page in bot.listpages(category,names=False,includeredirects=False):
		if page.namespace == 0:
			if checktext(page) == True:
				results.append(page.name)

	output = "== Minor planet articles with one sentence and no references ==\n<sup>Updated ~~~~~ by [[User:Theo's Little Bot|]]</sup>"

	results = sorted(set(results))
	for result in results:
		output += "\n# [[{}]]".format(result)

	page = site.Pages["User:Theo's Little Bot/Minor planets"]
	page.save(output,summary="[[WP:BOT|Bot]]: Updating minor planets report")