Manual talk:Pywikibot/template.py

-remove doesn't remove
Running template.py -remove template_name gives me a bunch of results like: No changes were necessary in Help:Copying Any idea why it won't remove the template? --w:User:Naught101 00:54, 30 June 2008 (UTC)


 * Syntax? Maybe run it  Do You have the newest version, have You visited  (they are quite helpful there). Best regards, --birdy geimfyglið  (:> )=  ∇  11:12, 30 June 2008 (UTC)

New entry for regex matches
When there is a space between {{Template: and the template being replaced, i.e. {{template: User moxie}} cf. – xeno ( talk ) 15:36, 22 April 2009 (UTC)

no results when template exists (solved)
I have the page:


 * http://dead-rising-wiki.com/w/index.php?title=Template:Cement_Saw

And get the result:

C:\Users\t\Desktop\pywikipedia>template.py "Cement Saw" "Cement Saw test" unicode test: triggers problem #3081100 Getting references to Template:Cement Saw via API... 0 pages were changed.

Is this a problem with the family file? Can I get a result of what page pywikipedia  is pulling from? I suspect it is pulling from the wrong pages.

thank you for your time. Adamtheclown 05:50, 18 November 2010 (UTC)

C:\Users\t\Desktop\pywikipedia> template.py "TOCright" "TOCright test" unicode test: triggers problem #3081100 Getting references to Template:TOCright via API... Getting 3 pages from dead:en... Traceback (most recent call last): File "C:\Users\t\Desktop\pywikipedia\pagegenerators.py", line 1268, in __iter_ _   for loaded_page in self.preload(somePages): File "C:\Users\t\Desktop\pywikipedia\pagegenerators.py", line 1287, in preload

pywikibot.getall(site, pagesThisSite) File "C:\Users\t\Desktop\pywikipedia\wikipedia.py", line 4322, in getall _GetAll(site, pages, throttle, force).run File "C:\Users\t\Desktop\pywikipedia\wikipedia.py", line 3955, in run data = self.getData File "C:\Users\t\Desktop\pywikipedia\wikipedia.py", line 4138, in getData response, data = self.site.postForm(address, predata) File "C:\Users\t\Desktop\pywikipedia\wikipedia.py", line 5164, in postForm cookies=self.cookies(sysop = sysop)) File "C:\Users\t\Desktop\pywikipedia\wikipedia.py", line 5215, in postData    raise PageNotFound(u'Page %s could not be retrieved. Check your family file ?' % url) PageNotFound: Page http://www.dead-rising-wiki.com/w/index.php/index.php?title=S pecial:Export&useskin=monobook could not be retrieved. Check your family file ? Page http://www.dead-rising-wiki.com/w/index.php/index.php?title=Special:Export& useskin=monobook could not be retrieved. Check your family file ? 0 pages were changed.

It looks like the bot is pulling from the wrong page:


 * http://www.dead-rising-wiki.com/w/index.php/index.php?title=Special:Export&useskin=monobook

It is listing two index.php, not one. Maybe I should change my family file? Adamtheclown 08:34, 19 November 2010 (UTC)
 * I figured it out by changing my family file:


 * 1) -*- coding: utf-8  -*-

import family

class Family(family.Family):
 * 1) The official Beta Wiki.

def __init__(self):

family.Family.__init__(self) self.name = 'dead' #Set the family name; this should be the same as in the filename.

self.langs = { 'en': 'www.dead-rising-wiki.com', #Put the hostname here. }

def version(self, code): return "1.16.0" #The MediaWiki version used. Not very important in most cases.

def scriptpath(self, code): return '/w/' #The value of on this wiki

def apipath(self, code): return '/w/api.php' #The path of api.php

Problem solved. Adamtheclown 08:38, 19 November 2010 (UTC)

Replace old template with its parameter
Hi, is there any command to replace old template with all its parameters to a new template? For example:  to be replaced by

When I use, it replaces   with

Thanks, 👦 Rachmat ·  t 09:51, 7 October 2015 (UTC)

Remove template with summary provided
It was throwing the error: Traceback (most recent call last): File ".\scripts\template.py", line 369, in    main File ".\scripts\template.py", line 364, in main bot = TemplateRobot(preloadingGen, templates, **options) File ".\scripts\template.py", line 225, in __init__ builder = textlib._MultiTemplateMatchBuilder(site) UnboundLocalError: local variable 'site' referenced before assignment

I made the following change and it fixed it: builder = textlib._MultiTemplateMatchBuilder(site) to builder = textlib._MultiTemplateMatchBuilder(self.site) -- Prod (talk) 19:28, 11 March 2016 (UTC)