Manual talk:Pywikipediabot/template.py

From MediaWiki.org
Jump to: navigation, search
The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

[edit] -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 template.py -remove "templatename" Do You have the newest version, have You visited Template:Channel (they are quite helpful there). Best regards, --birdy geimfyglið (:> )=| 11:12, 30 June 2008 (UTC)

[edit] 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)

[edit] 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:
# -*- 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)

Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox