Manual talk:Pywikibot/template.py
Add topicAny user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).
-remove doesn't remove
[edit]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
template.py -remove "templatename"
Do You have the newest version, have You visited #pywikipediabot connect (they are quite helpful there). Best regards, --birdy geimfyglið (:> )=| ∇ 11:12, 30 June 2008 (UTC)
New entry for regex matches
[edit]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)
[edit]I have the page:
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:
# -*- coding: utf-8 -*- import family # The official Beta Wiki. class Family(family.Family): 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 {{SCRIPTPATH}} 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)
Note that the above conversation may have been edited or added to since the transfer. If in doubt, check the edit history.
Replace old template with its parameter
[edit]Hi, is there any command to replace old template with all its parameters to a new template? For example: {{bar|1}}
to be replaced by {{--}}
When I use python pwb.py scripts/template.py "bar" "--"
, it replaces {{bar|1}}
with {{--|1}}
Thanks, 👦 Rachmat · t 09:51, 7 October 2015 (UTC)
Remove template with summary provided
[edit]It was throwing the error:
Traceback (most recent call last): File ".\scripts\template.py", line 369, in <module> 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)
How to remove a template with parameter
[edit]I want to remove the Template "Tranlation" with parameter "st" (Translation|st),What should I do?SteveZihang (talk) 03:17, 24 January 2017 (UTC)