# Completes a template containing the editcount of a user, # so it can then be used by other templates/userboxes that # take the edit count of a user as a parameter. # Sandbox for testing, not a complete bot import wikipedia, userlib, re site = wikipedia.getSite() templateLocation = 'User:EditCountBot/Counter' for page in wikipedia.Page(site, templateLocation).getReferences(follow_redirects=False,onlyTemplateInclusion=True): text = page.get() for username in re.findall(r'\{\{.*?user=(.*?)\|.*?\}\}', text, re.I): user = userlib.User(site, username) editCount = str(user.editCount()) newTemplate = '{{' + templateLocation + '|user=' + username + '|count=' + editCount + '}}' text = re.sub(r'\{\{User:EditCountBot/Counter\|.*?user=EdoDodo.*?\}\}', newTemplate, text) wikipedia.showDiff(page.get(), text)