Manual talk:Pywikipediabot/Archive 1

CVS diff
You recommend using "cvs diff". Surely you want to recommend "cvs diff -u"? This gives a much more robust diff format than the default (submitting patches in a format other than unidiff is a common newbie dev mistake). Subversion uses that format by default, and is nicer than CVS in lots of other ways, so you might want to move to that instead :) Hairy Dude 08:25, 7 March 2006 (UTC)
 * pywikipediabot is a framework for which most of the users have installed CVS tools, and these users are not using CVS for anything else. It is bad enough that we required normal users to use developers tools to use the programs, migrating to subversion will not happen any time soon! You are completely right that -u should be used to generate patches against cvs. Rob Hooft 12:01, 9 April 2006 (UTC)

CVS instructions
I think the CVS instructions need updating. They don't seem to work- did the CVS repository move to another address? --129.21.121.171 18:33, 16 May 2006 (UTC)


 * Ok, it seems to be working now. I guess the CVS server did move. --129.21.121.171 04:05, 23 May 2006 (UTC)

Unicode problem
I am writing a bot to run on Hindi Wikipedia. I am using python wikimedia framework. I am getting an error, "UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: unexpected code byte" when executing the following code,

f = codecs.open('hi-towns.csv', 'r', config.textfile_encoding) x = f.read.decode('utf8')

Any help will be greatly appreciated. Thanks, Ganeshk 03:54, 16 July 2006 (UTC)
 * This was solved. - Ganeshk 15:15, 16 July 2006 (UTC)

Not updated?
TortoiseCVS does not seem to work with Pywikipedia, and the link http://sourceforge.net/cvs/?group_id=93107 seems to be dead. - Soulkeeper 19:12, 1 September 2006 (UTC)

python-xml
On another list it mentioned that the python-xml libraries were needed as well. With Fedora Linux I got that using 'yum install PyXML'. Other systems probably vary. 143.52.82.248 13:57, 1 November 2006 (UTC)

doc included in framework
I extracted the documentation included in wkipedia.py with this : import wikipedia import codecs

manuel = file("manuel.txt", "w") doc = wikipedia.__doc__

for ligne in doc: manuel.write(ligne)

Maybe one can include this somewhere ?

Library to get and put pages on a MediaWiki.

Contents of the library (objects and functions to be used outside, situation late August 2004)

Classes: Page: A MediaWiki page __init__             : Page(Site, Title) - the page with title Title on wikimedia site Site title                : The name of the page, in a form suitable for an interwiki link urlname              : The name of the page, in a form suitable for a URL titleWithoutNamespace : The name of the page, with the namespace part removed section              : The section of the page (the part of the name after '#') sectionFreeTitle     : The name without the section part aslink               : The name of the page in the form Title or lang:Title site                 : The wiki this page is in    encoding              : The encoding of the page isAutoTitle          : If the title is a well known, auto-translatable title autoFormat           : Returns (dictName, value), where value can be a year, date, etc., and dictName is 'YearBC', 'December', etc.   isCategory            : True if the page is a category, false otherwise isImage              : True if the page is an image, false otherwise

get (*)              : The text of the page exists (*)           : True if the page actually exists, false otherwise isRedirectPage (*)   : True if the page is a redirect, false otherwise isEmpty (*)          : True if the page has 4 characters or less content, not counting interwiki and category links interwiki (*)        : The interwiki links from the page (list of Pages) categories (*)       : The categories the page is in (list of Pages) linkedPages (*)      : The normal pages linked from the page (list of Pages) imagelinks (*)       : The pictures on the page (list of Pages) templates (*)        : All templates referenced on the page (list of strings) getRedirectTarget (*) : The page the page redirects to   isDisambig (*)        : True if the page is a disambiguation page getReferences        : List of pages linking to the page namespace            : The namespace in which the page is    permalink (*)         : The url of the permalink of the current version move                 : Move the page to another title

put(newtext)         : Saves the page delete               : Deletes the page (requires being logged in)

(*) : This loads the page if it has not been loaded before; permalink might even reload it if it has been loaded before

Site: a MediaWiki site messages             : There are new messages on the site forceLogin: Does not continue until the user has logged in to the site getUrl: Retrieve an URL from the site

Special pages: Dynamic pages: allpages: Special:Allpages newpages: Special:Newpages longpages: Special:Longpages shortpages: Special:Shortpages categories: Special:Categories

Cached pages: deadendpages: Special:Deadendpages ancientpages: Special:Ancientpages lonelypages: Special:Lonelypages uncategorizedcategories: Special:Uncategorizedcategories uncategorizedpages: Special:Uncategorizedpages unusedcategories: Special:Unusuedcategories

Other functions: getall: Load pages via Special:Export setAction(text): Use 'text' instead of "Wikipedia python library" in   editsummaries argHandler(text): Checks whether text is an argument defined on wikipedia.py   (these are -family, -lang, -log and others) translate(xx, dict): dict is a dictionary, giving text depending on language, xx is a language. Returns the text in the most applicable language for the xx: wiki

output(text): Prints the text 'text' in the encoding of the user's console. input(text): Asks input from the user, printing the text 'text' first. showDiff(oldtext, newtext): Prints the differences between oldtext and newtext on the screen

getLanguageLinks(text,xx): get all interlanguage links in wikicode text 'text' in the form xx:pagename removeLanguageLinks(text): gives the wiki-code 'text' without any interlanguage links. replaceLanguageLinks(oldtext, new): in the wiki-code 'oldtext' remove the language links and replace them by the language links in new, a dictionary with the languages as keys and either Pages or titles as values getCategoryLinks(text,xx): get all category links in text 'text' (links in the   form xx:pagename) removeCategoryLinks(text,xx): remove all category links in 'text' replaceCategoryLinks(oldtext,new): replace the category links in oldtext by   those in new (new a list of category Pages) stopme: Put this on a bot when it is not or not communicating with the Wiki any longer. It will remove the bot from the list of running processes, and thus not slow down other bot threads anymore.

Error in article
(To work in Python25 http://www.python.org/download/, the files must be downloaded into the Python25 folder). I have installed Python25 and downloaded pywikipedia from cvs today, the pywikipedia files are on a different disk than the Python25 folder, and it works. I conclude that what this line claims is false. I am not 100% sure so I didn't edit it out myself. If anyone is 100% sure, please edit it out. Theroachman 23:47, 14 February 2007 (UTC)

using special characters
I would like to use the template.py, but run into one problem.

template.py "Tableheader 100" "Tableheader|100%"

Notice the %-sign in the example, it gets lost. Any idea, how it could be included?

Ok, found it: %% --GunterS 13:05, 3 March 2007 (UTC)

Dry run
Does anyone know how to run a bot, record edits that it would have made, but not actually make the edtits? (also known as a Dry-run)
 * Within this framework, you have to edit the code in wikipedia.py under the Site class, under the postData method so that "con.send(data)" line prints data instead, you'll have to comment out the rest of that method as well. This may cause other problems but it's the best place (As far as I know) to start. 138.67.78.236