User:Dantman/Pywikipediabot/Dantman-UserClone-Bot.py

""" This bot is used by Dantman to mirror his userpages across wikia. """
 * 1) -*- coding: utf-8  -*-

import sys, re import wikipedia, pagegenerators, catlib, config

msg = { 'en':u'Automatic Bot Userpage Cloning', }

def main: #Setup Familys for Wikia Involved anime = wikipedia.getSite(code=u'en', fam=u'anime') wikipedia.setAction(wikipedia.translate(anime, msg)) siteList = [] pageList = [ u'User:Dantman', u'User:Dantman/Contact', u'User:Dantman/WikIndex', u'User:Dantman/Adopted Wikia', u'User:Dantman/Administrated Wikia', u'User:Dantman/Aided Wikia', u'User:Dantman/TalkTop', u'User:Dantman/sig.main', u'User:Dantman/Clickthrough', u'User:Dantman/Curve', u'User:Dantman/Language Skills' ]	#Get Project Wiki Listing wikiaIds = [u'wikia'] page = wikipedia.Page(anime, u'Bots/Wiki', None, 4)#4=Project Namespace try: text = page.get r = re.compile(u'^.*\n?', re.UNICODE | re.DOTALL) text = re.sub(r, u'', text) r = re.compile(u'\n?.*$', re.UNICODE | re.DOTALL) text = re.sub(r, u'', text) r = re.compile(u'\n', re.UNICODE | re.MULTILINE | re.DOTALL) wikilist = re.split(r, text) r = re.compile(u'^#|^\s*$', re.UNICODE | re.MULTILINE | re.DOTALL) for wiki in wikilist: if not re.match(r, wiki): wikiaIds.append(wiki) except wikipedia.NoPage: return False; for wiki in wikiaIds: siteList.append(wikipedia.getSite(code=u'en', fam=wiki)) for page in pageList: wikipedia.output(u'Doing Page %s' % page) pagePage = wikipedia.Page(anime, page) pageSource = pagePage.get for site in siteList: sitePage = wikipedia.Page(site, page) siteSource = sitePage.get try: siteSource = sitePage.get except wikipedia.NoPage: wikipedia.output(u'Site %s has no %s page, creating it' % (site, page)) if siteSource != pageSource: wikipedia.output(u'Site \'%s\' page status: Needs Updating' % site) wikipedia.output(u'Updating page on %s' % site) sitePage.put(pageSource) else: wikipedia.output(u'Site \'%s\' page status: Ok' % site)

if __name__ == "__main__": try: main finally: wikipedia.stopme