Revision: 5846
Author: siebrand
Date: 2008-08-24 20:53:27 +0000 (Sun, 24 Aug 2008)
Log Message:
-----------
* set svn:keywords consistently
* remove execute bits
* add $Id$ where missing
* remove trailing whitespace
(only top directory done)
Modified Paths:
--------------
trunk/pywikipedia/CONTENTS
trunk/pywikipedia/LICENSE
trunk/pywikipedia/add_text.py
trunk/pywikipedia/articlenos.py
trunk/pywikipedia/blockpageschecker.py
trunk/pywikipedia/capitalize_redirects.py
trunk/pywikipedia/casechecker.py
trunk/pywikipedia/catall.py
trunk/pywikipedia/category_redirect.py
trunk/pywikipedia/catmove.pl
trunk/pywikipedia/checkimages.py
trunk/pywikipedia/clean_sandbox.py
trunk/pywikipedia/commons_category_redirect.py
trunk/pywikipedia/commonscat.py
trunk/pywikipedia/copyright_clean.py
trunk/pywikipedia/copyright_put.py
trunk/pywikipedia/daemonize.py
trunk/pywikipedia/date.py
trunk/pywikipedia/delinker.py
trunk/pywikipedia/diskcache.py
trunk/pywikipedia/distrib
trunk/pywikipedia/djvutext.py
trunk/pywikipedia/editarticle.py
trunk/pywikipedia/extract_wikilinks.py
trunk/pywikipedia/family.py
trunk/pywikipedia/featuredcount.py
trunk/pywikipedia/fixing_redirects.py
trunk/pywikipedia/followlive.py
trunk/pywikipedia/gui.py
trunk/pywikipedia/imagecopy.py
trunk/pywikipedia/imagerecat.py
trunk/pywikipedia/imagetransfer.py
trunk/pywikipedia/imageuncat.py
trunk/pywikipedia/inline_images.py
trunk/pywikipedia/interwiki.py
trunk/pywikipedia/interwiki_graph.py
trunk/pywikipedia/isbn.py
trunk/pywikipedia/login.py
trunk/pywikipedia/lonelypages.py
trunk/pywikipedia/maintainer.py
trunk/pywikipedia/makecat.py
trunk/pywikipedia/misspelling.py
trunk/pywikipedia/mysql_autoconnection.py
trunk/pywikipedia/noreferences.py
trunk/pywikipedia/nowcommons.py
trunk/pywikipedia/pagegenerators.py
trunk/pywikipedia/pageimport.py
trunk/pywikipedia/piper.py
trunk/pywikipedia/protect.py
trunk/pywikipedia/query.py
trunk/pywikipedia/rciw.py
trunk/pywikipedia/rcsort.py
trunk/pywikipedia/redirect.py
trunk/pywikipedia/reflinks.py
trunk/pywikipedia/replace.py
trunk/pywikipedia/revertbot.py
trunk/pywikipedia/saveHTML.py
trunk/pywikipedia/solve_disambiguation.py
trunk/pywikipedia/spellcheck.py
trunk/pywikipedia/standardize_interwiki.py
trunk/pywikipedia/standardize_notes.py
trunk/pywikipedia/table2wiki.py
trunk/pywikipedia/template.py
trunk/pywikipedia/titletranslate.py
trunk/pywikipedia/unlink.py
trunk/pywikipedia/upload.py
trunk/pywikipedia/warnfile.py
trunk/pywikipedia/watchlist.py
trunk/pywikipedia/weblinkchecker.py
trunk/pywikipedia/welcome.py
trunk/pywikipedia/wikicomserver.py
trunk/pywikipedia/wikipedia.py
trunk/pywikipedia/wikipediatools.py
trunk/pywikipedia/wiktionary.py
trunk/pywikipedia/wiktionarytest.py
Property Changed:
----------------
trunk/pywikipedia/CONTENTS
trunk/pywikipedia/LICENSE
trunk/pywikipedia/add_text.py
trunk/pywikipedia/articlenos.py
trunk/pywikipedia/blockpageschecker.py
trunk/pywikipedia/category_redirect.py
trunk/pywikipedia/catmove.pl
trunk/pywikipedia/commons_category_redirect.py
trunk/pywikipedia/commonscat.py
trunk/pywikipedia/copyright_clean.py
trunk/pywikipedia/copyright_put.py
trunk/pywikipedia/daemonize.py
trunk/pywikipedia/delinker.py
trunk/pywikipedia/diskcache.py
trunk/pywikipedia/distrib
trunk/pywikipedia/djvutext.py
trunk/pywikipedia/featured.py
trunk/pywikipedia/featuredcount.py
trunk/pywikipedia/fixing_redirects.py
trunk/pywikipedia/followlive.py
trunk/pywikipedia/generate_user_files.py
trunk/pywikipedia/imagerecat.py
trunk/pywikipedia/imageuncat.py
trunk/pywikipedia/lonelypages.py
trunk/pywikipedia/maintainer.py
trunk/pywikipedia/noreferences.py
trunk/pywikipedia/pageimport.py
trunk/pywikipedia/piper.py
trunk/pywikipedia/protect.py
trunk/pywikipedia/rciw.py
trunk/pywikipedia/reflinks.py
trunk/pywikipedia/revertbot.py
trunk/pywikipedia/version.py
trunk/pywikipedia/welcome.py
Modified: trunk/pywikipedia/CONTENTS
===================================================================
--- trunk/pywikipedia/CONTENTS 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/CONTENTS 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,5 +1,5 @@
-This is a package to build robots for MediaWiki wikis like Wikipedia. Some
-example robots are included.
+This is a package to build robots for MediaWiki wikis like Wikipedia. Some
+example robots are included.
=======================================================================
PLEASE DO NOT PLAY WITH THIS PACKAGE. These programs can actually
@@ -52,9 +52,9 @@
followlive.py : Periodically grab the list of new articles and analyze
them. If the article is too short, a menu will let you
easily add a template.
-get.py : Script to get a page and write its contents to standard
+get.py : Script to get a page and write its contents to standard
output.
-login.py : Log in to an account on your "home" wiki.
+login.py : Log in to an account on your "home" wiki.
splitwarning.py : split an interwiki.log file into warning files for each
separate language. suggestion: Zip the created
files up, put them somewhere on the internet, and
@@ -71,10 +71,10 @@
detailed infortion on possiblities.
sqldump.py : Extract information from local cur SQL dump
files, like the ones at
http://download.wikimedia.org
-rcsort.py : A tool to see the recentchanges ordered by user instead
+rcsort.py : A tool to see the recentchanges ordered by user instead
of by date.
-threadpool.py :
-xmlreader.py :
+threadpool.py :
+xmlreader.py :
watchlist.py : Allows access to the bot account's watchlist.
wikicomserver.py : This library allows the use of the pywikipediabot
directly from COM-aware applications.
@@ -139,7 +139,7 @@
text files. The bot can either work on a set of given
pages or crawl an SQL dump.
saveHTML.py : Downloads the HTML-pages of articles and images.
-selflink.py : This bot goes over multiple pages of the home wiki,
+selflink.py : This bot goes over multiple pages of the home wiki,
searches for selflinks, and allows removing them.
solve_disambiguation.py: Interactive robot doing disambiguation.
speedy_delete.py : This bot load a list of pages from the category of
@@ -163,9 +163,9 @@
unusedfiles.py : Bot appends some text to all unused images and other
text to the respective uploaders.
upload.py : upload an image to a wiki.
-us-states.py : A robot to add redirects to cities for US state
+us-states.py : A robot to add redirects to cities for US state
abbreviations.
-warnfile.py : A robot that parses a warning file created by
+warnfile.py : A robot that parses a warning file created by
interwiki.py on another language wiki, and
implements the suggested changes without verifying
them.
@@ -178,7 +178,7 @@
=== Directories ===
archive : Contains old bots.
-category :
+category :
copyright : Contains information retrieved by copyright.py
deadlinks : Contains information retrieved by weblinkchecker.py
disambiguations : If you run solve_disambiguation.py with the -primary
@@ -187,7 +187,7 @@
languages, encodings etc.
featured : Stored featured article in cache file.
interwiki_dump : If the interwiki bot is interrupted, it will store
- a dump file here. This file will be read when using
+ a dump file here. This file will be read when using
the interwiki bot with -restore or -continue.
interwiki_graphs : Contains graphs for interwiki_graph.py
logs : Contains logfiles.
@@ -229,7 +229,7 @@
python interwiki.py -help
-You need to have at least python version 2.4 (
http://www.python.org/download/)
+You need to have at least python version 2.4 (
http://www.python.org/download/)
installed on your computer to be able to run any of the code in this package.
Although some of the code may work on python version 2.3, support for older
versions of python is not planned.
@@ -239,7 +239,7 @@
it or where you have your copy of the SVN sources.
Before you run any of the programs, you need to create a file named
-user-config.py in your current directory. It needs at least two lines:
+user-config.py in your current directory. It needs at least two lines:
The first line should set your real name; this will be used to identify you
when the robot is making changes, in case you are not logged in. The
second line sets the code of your home language. The file should look like:
Property changes on: trunk/pywikipedia/CONTENTS
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/LICENSE
===================================================================
--- trunk/pywikipedia/LICENSE 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/LICENSE 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,6 +1,6 @@
Copyright (c) 2005 The PyWikipediaBot team
-Permission is hereby granted, free of charge, to any person obtaining a copy
+Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
Property changes on: trunk/pywikipedia/LICENSE
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/add_text.py
===================================================================
--- trunk/pywikipedia/add_text.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/add_text.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -282,7 +282,7 @@
# Main Loop
for page in generator:
(status, always) = add_text(page, addText, summary, regexSkip, regexSkipUrl,
always, up, True)
-
+
if __name__ == "__main__":
try:
main()
Property changes on: trunk/pywikipedia/add_text.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/articlenos.py
===================================================================
--- trunk/pywikipedia/articlenos.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/articlenos.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -10,6 +10,7 @@
# Author: Balasyum
#
http://hu.wikipedia.org/wiki/User:Balasyum
# License : LGPL
+__version__ = '$Id$'
from ircbot import SingleServerIRCBot
from irclib import nm_to_n, nm_to_h, irc_lower, ip_numstr_to_quad, ip_quad_to_numstr
Property changes on: trunk/pywikipedia/articlenos.py
___________________________________________________________________
Name: svn:executable
- *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/pywikipedia/blockpageschecker.py
===================================================================
--- trunk/pywikipedia/blockpageschecker.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/blockpageschecker.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -88,7 +88,7 @@
}
# Regex to get the total-protection template
templateTotalProtection = {
- 'en': None,
+ 'en': None,
'it':[r'\{\{(?:[Tt]emplate:|)[Aa]vvisoblocco(?:|[
_]scad\|(?:.*?)|minaccia|cancellata)\}\}',
r'\{\{(?:[Tt]emplate:|)(?:[Cc][Tt]|[Cc]anc
fatte|[Cc][Ee])\}\}', r'<div class="toccolours[ _]itwiki[ _]template[
_]avviso">(?:\s|\n)*?[Qq]uesta pagina'],
'fr':[ur'\{\{(?:[Tt]emplate:|[Mm]odèle:|)[Pp]rotection(|[^\}]*)\}\}',
@@ -98,14 +98,14 @@
}
# Regex to get the semi-protection move template
templateSemiMoveProtection = {
- 'en': None,
+ 'en': None,
'it':[r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccospostamento(?:|[
_]scad\|.*?|\|.*?)\}\}'],
'ja':[ur'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)移動半保護(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*(?:\r\n|)*'],
'zh':[r'\{\{(?:[Tt]emplate:|)Protected|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Mini-protected|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Protected-logo|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)'],
}
-# Regex to get the total-protection move template
+# Regex to get the total-protection move template
templateTotalMoveProtection = {
- 'en': None,
+ 'en': None,
'it':[r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccospostamento(?:|[
_]scad\|.*?|\|.*?)\}\}'],
'ja':[ur'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)移動保護(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*(?:\r\n|)*'],
'zh':[ur'\{\{(?:[Tt]emplate:|)Protected|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Mini-protected|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Protected-logo|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)'],
@@ -175,7 +175,7 @@
pathWiki = site.family.nicepath(site.lang)
url = 'http://%s%s%s?&redirect=no' % (wikipedia.getSite().hostname(),
pathWiki, page.urlname())
while 1:
- if quest.lower() in ['b', 'B']:
+ if quest.lower() in ['b', 'B']:
webbrowser.open(url)
break
elif quest.lower() in ['g', 'G']:
@@ -235,7 +235,7 @@
TSMP = wikipedia.translate(site, templateSemiMoveProtection)
TTMP = wikipedia.translate(site, templateTotalMoveProtection)
TNR = wikipedia.translate(site, templateNoRegex)
-
+
category = wikipedia.translate(site, categoryToCheck)
commentUsed = wikipedia.translate(site, comment)
if not generator:
@@ -268,11 +268,11 @@
"""
# This check does not work :
# PreloadingGenerator cannot set correctly page.editRestriction
- # (see bug #1949476 )
+ # (see bug #1949476 )
if not page.canBeEdited():
wikipedia.output("%s is sysop-protected : this account can't edit
it! Skipping..." % pagename)
continue
- """
+ """
editRestr = restrictions['edit']
if editRestr and editRestr[0] == 'sysop':
try:
@@ -280,7 +280,7 @@
except:
wikipedia.output("%s is sysop-protected : this account can't
edit it! Skipping..." % pagename)
continue
-
+
# Understand, according to the template in the page, what should be the
protection
# and compare it with what there really is.
TemplateInThePage = understandBlock(text, TTP, TSP, TSMP, TTMP)
@@ -297,7 +297,7 @@
wikipedia.output(u'The page is editable for all, deleting the
template...')
elif editRestr[0] == 'sysop':
- # total edit protection
+ # total edit protection
if TemplateInThePage[0] == 'sysop-total' and TTP != None:
msg = 'The page is protected to the sysop'
if not moveBlockCheck:
@@ -309,7 +309,7 @@
elif TSP != None:
# implicitely editRestr[0] = 'autoconfirmed', edit-Semi-protection
- if TemplateInThePage[0] == 'autoconfirmed-total':
+ if TemplateInThePage[0] == 'autoconfirmed-total':
msg = 'The page is editable only for the autoconfirmed users'
if not moveBlockCheck:
msg += ', skipping...'
@@ -321,7 +321,7 @@
if changes == 0:
# We tried to fix edit-protection templates, but it did not work.
wikipedia.output('Warning : No edit-protection template could be
found')
-
+
if moveBlockCheck:
# checking move protection now
moveRestr = restrictions['move']
@@ -371,7 +371,7 @@
break
except wikipedia.ServerError:
# Sometimes there is this error that's quite annoying
because
- # can block the whole process for nothing.
+ # can block the whole process for nothing.
errorCount += 1
if errorCount < 5:
wikipedia.output(u'Server Error! Wait..')
@@ -393,7 +393,7 @@
# Break only if the errors are one after the other
errorCount = 0
break
-
+
if __name__ == "__main__":
try:
main()
Property changes on: trunk/pywikipedia/blockpageschecker.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/capitalize_redirects.py
===================================================================
--- trunk/pywikipedia/capitalize_redirects.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/capitalize_redirects.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -88,7 +88,7 @@
else:
wikipedia.output(u'%s already exists, skipping...\n'
% page_t.title())
-
+
def main():
gen = None
source = None
@@ -144,7 +144,7 @@
namespaces.append(arg[11:])
else:
commandline_replacements.append(arg)
-
+
if source == 'textfile':
gen = pagegenerators.TextfilePageGenerator(textfilename)
elif source == 'category':
Modified: trunk/pywikipedia/casechecker.py
===================================================================
--- trunk/pywikipedia/casechecker.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/casechecker.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -76,14 +76,14 @@
# These words are always in one language, even though they could be typed in both
alwaysInLocal = [ u'СССР', u'Как', u'как' ]
alwaysInLatin = [ u'II', u'III' ]
-
+
localUpperLtr = u'ЁІЇЎАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯҐ'
localLowerLtr = u'ёіїўабвгдежзийклмнопрстуфхцчшщъыьэюяґ'
localLtr = localUpperLtr + localLowerLtr
-
+
localSuspects = u'АВЕКМНОРСТХІЁЇаеорсухіёї'
latinSuspects = u'ABEKMHOPCTXIËÏaeopcyxiëï'
-
+
localKeyboard = u'йцукенгшщзфывапролдячсмить' # possibly try to fix one
character mistypes in an alternative keyboard layout
latinKeyboard = u'qwertyuiopasdfghjklzxcvbnm'
@@ -94,7 +94,7 @@
whitelists = {
'ru': u'ВП:КЛ/Whitelist'
}
-
+
latLtr = u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
lclClrFnt = u'<font color=green>'
@@ -153,9 +153,9 @@
self.params = { 'action' : 'query',
'generator' : 'allpages',
- 'gaplimit' : self.aplimit,
+ 'gaplimit' : self.aplimit,
'gapfilterredir': 'nonredirects'}
-
+
if self.links:
self.params['prop'] = 'links|categories'
@@ -194,7 +194,7 @@
badPtrnStr = u'([%s][%s]|[%s][%s])' % (self.latLtr, self.localLtr,
self.localLtr, self.latLtr)
self.badWordPtrn = re.compile(u'[%s%s]*%s[%s%s]*' % (self.latLtr,
self.localLtr, badPtrnStr, self.latLtr, self.localLtr) )
-
+
# Get whitelist
if self.site.lang in self.whitelists:
wlpage = self.whitelists[self.site.lang]
Modified: trunk/pywikipedia/catall.py
===================================================================
--- trunk/pywikipedia/catall.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/catall.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -44,7 +44,7 @@
print ("Empty line: if the first, don't change. Otherwise: Ready.")
print ("-: I made a mistake, let me start over.")
print ("?: Give the text of the page with GUI.")
- print ("??: Give the text of the page in console.")
+ print ("??: Give the text of the page in console.")
print ("xx: if the first, remove all categories and add no new.")
print ("q: quit.")
while flag == False:
@@ -60,7 +60,7 @@
newtext = editor.edit(pagetext)
elif choice =="??":
wikipedia.output(pagetext[0:length])
- length = length+500
+ length = length+500
elif choice=="xx" and chosen==[]:
chosen = None
flag=True
Modified: trunk/pywikipedia/category_redirect.py
===================================================================
--- trunk/pywikipedia/category_redirect.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/category_redirect.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -10,6 +10,7 @@
has such a category defined)
"""
+__version__ = '$Id$'
import wikipedia, catlib
import pagegenerators
@@ -80,7 +81,7 @@
def __init__(self, often):
self.cooldown = 6 # days
self.often = often
-
+
# Localization:
# Category that contains all redirected category pages
@@ -160,7 +161,7 @@
u"ロボットによる: 移行中のカテゴリとしてタグ付け",
'no':
u"Robot: Legger til vedlikeholdsmal for kategoriomdirigering",
- }
+ }
self.dbl_redir_comment = {
'_default': u"Robot: fixing double-redirect",
@@ -561,7 +562,7 @@
u"Robot: fixing category redirect parameter format")
self.log_text.append(
u"* Removed category prefix from parameter in %s"
- % cat.aslink(textlink=True))
+ % cat.aslink(textlink=True))
wikipedia.output(u"")
wikipedia.output(u"Checking %s destination categories" % len(destmap))
Property changes on: trunk/pywikipedia/category_redirect.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/pywikipedia/catmove.pl
===================================================================
--- trunk/pywikipedia/catmove.pl 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/catmove.pl 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,4 +1,5 @@
#!/usr/bin/perl
+# $Id$
# This Perl script takes a list of category moves or removes to make and uses
category.py.
# The input format is as follows:
@@ -10,7 +11,7 @@
# If you want to use an edit summary, then pass it in as a parameter, i.e.,
# perl catmove.pl "Emptying dead category" < catmoves.txt
# Note that if your summary has multiple words in it then enclose it in quotes.
-#
+#
# To set edit summaries, you can also preface a line with a semicolon ;
# That will be the edit summary for all subsequent executions ... unless you modify the
# edit summary again with another semicolon. In this way you can take care of many days
Property changes on: trunk/pywikipedia/catmove.pl
___________________________________________________________________
Name: svn:executable
- *
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/checkimages.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -73,7 +73,7 @@
#
# (C) Kyle/Orgullomoore, 2006-2007 (newimage.py)
-# (C) Siebrand Mazeland, 2007
+# (C) Siebrand Mazeland, 2007
# (C) Filnik, 2007-2008
#
# Distributed under the terms of the MIT license.
@@ -103,7 +103,7 @@
'ta' :u'\n{{subst:nld}}',
'zh' :u'{{subst:No license/auto}}',
}
-
+
# Text that the bot will try to see if there's already or not. If there's a
# {{ I'll use a regex to make a better check.
# This will work so:
@@ -111,7 +111,7 @@
# If there's not a {{ it will work as usual (if x in Text)
txt_find = {
'commons':[u'{{no license', u'{{nld', u'{{no
permission since'],
- 'de':[u'{{DÜP', u'{{Dateiüberprüfung'],
+ 'de':[u'{{DÜP', u'{{Dateiüberprüfung'],
'en':[u'{{nld', u'{{no license'],
'hu':[u'{{nincsforrás',u'{{nincslicenc'],
'it':[u'{{unverdata', u'{{unverified'],
@@ -120,10 +120,10 @@
'ko':[u'{{출처 없음', u'{{라이선스 없음',u'{{Unknown',],
'zh':[u'{{no source', u'{{unknown', u'{{No
license',],
}
-
+
# Summary for when the will add the no source
comm = {
- 'ar' :u'بوت: التعليم على ملف مرفوع حديثا غير موسوم',
+ 'ar' :u'بوت: التعليم على ملف مرفوع حديثا غير موسوم',
'commons':u'Bot: Marking newly uploaded untagged file',
'de' :u'Bot: Markierung als Bild ohne Lizenz',
'en' :u'Bot: Marking newly uploaded untagged file',
@@ -147,10 +147,10 @@
'ko' :u'{{환영}}\n~~~~\n',
'zh' :u'{{subst:welcome|sign=~~~~}}',
}
-
+
# Summary that the bot use when it notify the problem with the image's license
comm2 = {
- 'ar' :u"بوت: طلب معلومات المصدر." ,
+ 'ar' :u"بوت: طلب معلومات المصدر." ,
'commons':u"Bot: Requesting source information." ,
'de' :u'Bot:Notify User',
'en' :u"Bot: Requesting source information." ,
@@ -163,7 +163,7 @@
'ta' :u'தானியங்கி:மூலம் வழங்கப்படா படிமத்தை சுட்டுதல்',
'zh' :u'機器人:告知用戶',
}
-
+
# if the file has an unknown extension it will be tagged with this template.
# In reality, there aren't unknown extension, they are only not allowed...
delete_immediately = {
@@ -177,7 +177,7 @@
'ta' :u'{{delete|இந்தக் கோப்பு .%s என்றக் கோப்பு நீட்சியைக்
கொண்டுள்ளது.}}',
'zh' :u'{{delete|未知檔案格式%s}}',
}
-
+
# The header of the Unknown extension's message.
delete_immediately_head = {
'commons':u"\n== Unknown extension! ==\n",
@@ -189,10 +189,10 @@
'ta' :u'\n== இனங்காணப்படாத கோப்பு நீட்சி! ==\n',
'zh' :u'\n==您上載的檔案格式可能有誤==\n',
}
-
+
# Text that will be add if the bot find a unknown extension.
delete_immediately_notification = {
- 'ar' :u'الملف [[:Image:%s]] يبدو أن امتداده خاطيء, من
فضلك تحقق. ~~~~',
+ 'ar' :u'الملف [[:Image:%s]] يبدو أن امتداده خاطيء, من
فضلك تحقق. ~~~~',
'commons':u'The [[:Image:%s]] file seems to have a wrong
extension, please check. ~~~~',
'en' :u'The [[:Image:%s]] file seems to have a wrong
extension, please check. ~~~~',
'hu' :u'A [[:Kép:%s]] fájlnak rossz a kiterjesztése,
kérlek ellenőrízd. ~~~~',
@@ -203,7 +203,7 @@
}
# Summary of the delate immediately. (f.e: Adding {{db-meta|The file has .%s as
extension.}})
del_comm = {
- 'ar' :u'بوت: إضافة %s',
+ 'ar' :u'بوت: إضافة %s',
'commons':u'Bot: Adding %s',
'en' :u'Bot: Adding %s',
'hu' :u'Robot:"%s" hozzáadása',
@@ -213,11 +213,11 @@
'ta' :u'Bot: Adding %s',
'zh' :u'機器人: 正在新增 %s',
}
-
+
# This is the most important header, because it will be used a lot. That's the header
that the bot
# will add if the image hasn't the license.
nothing_head = {
- 'ar' :u"\n== صورة بدون ترخيص ==\n",
+ 'ar' :u"\n== صورة بدون ترخيص ==\n",
'commons':u"",# Nothing, the template has already the
header inside.
'de' :u"\n== Bild ohne Lizenz ==\n",
'en' :u"\n== Image without license ==\n",
@@ -243,7 +243,7 @@
'ta' :u'\n{{subst:Di-no license-notice|படிமம்:%s}} ~~~~
',
'zh' :u'\n{{subst:Uploadvionotice|Image:%s}} ~~~~ ',
}
-
+
# This is a list of what bots used this script in your project.
# NOTE: YOUR Botnick is automatically added. It's not required to add it twice.
bot_list = {
@@ -256,7 +256,7 @@
'ta' :[u'TrengarasuBOT'],
'zh' :[u'alexbot'],
}
-
+
# The message that the bot will add the second time that find another license problem.
second_message_without_license = {
'commons':None,
@@ -293,7 +293,7 @@
'ta' :u'Trengarasu/commonsimages',
'zh' :u'User:Alexsh/checkimagereport',
}
-# Adding the date after the signature.
+# Adding the date after the signature.
timeselected = u' ~~~~~'
# The text added in the report
report_text = {
@@ -321,7 +321,7 @@
'ta' :u'தானியங்கி:பட்டியலை இற்றைப்படுத்தல்',
'zh' :u'機器人:更新記錄',
}
-
+
# If a template isn't a license but it's included on a lot of images, that can be
skipped to
# analise the image without taking care of it. (the template must be in a list)
# Warning: Don't add template like "en, de, it" because they are already in
(added in the code, below
@@ -347,7 +347,7 @@
'it':u'Progetto:Coordinamento/Immagini/Bot/WhiteTemplates',
'ko': u'User:Kwjbot_IV/whitetemplates/list',
}
-
+
# Template added when the bot finds only an hidden template and nothing else.
# Note: every __botnick__ will be repleaced with your bot's nickname (feel free not
to use if you don't need it)
HiddenTemplateNotification = {
@@ -435,7 +435,7 @@
else:
time_zone = unicode(time.strftime(u"%d %b %Y %H:%M:%S (UTC)",
time.gmtime()))
wikipedia.output(u"%s%s" % (message, time_zone))
-
+
class EmailSender(wikipedia.Page):
""" Class to send emails through the Wikipedia's dedicated page.
"""
def __init__(self, site, user):
@@ -447,7 +447,7 @@
page = '%s/%s' % (self.page_special_name, self.user)
self.page = page
wikipedia.Page.__init__(self, site, page, None, 0)
-
+
def send(self, subject, text, prompt = True):
""" Send an email through wikipedia's page.
"""
host = self.site().hostname()
@@ -496,7 +496,7 @@
# Commento = Summary in italian
self.commento = wikipedia.translate(self.site, comm)
# Adding the bot's nickname at the notification text if needed.
- botolist = wikipedia.translate(self.site, bot_list)
+ botolist = wikipedia.translate(self.site, bot_list)
project = wikipedia.getSite().family.name
bot = config.usernames[project]
botnick = bot[self.site.lang]
@@ -509,7 +509,7 @@
self.image_namespace = "%s:" % image_n # Example:
"User_talk:"
def setParameters(self, image):
""" Function to set parameters, now only image but maybe it can be
used for others in "future" """
- self.image = image
+ self.image = image
def report(self, newtext, image_to_report, notification = None, head = None,
notification2 = None, unver = True, commTalk = None, commImage = None):
""" Function to make the reports easier (or I hope so).
"""
@@ -579,7 +579,7 @@
testoa = p.get()
except wikipedia.NoPage:
wikipedia.output(u'%s has been deleted...' % p.title())
- # We have a problem! Report and exit!
+ # We have a problem! Report and exit!
return False
# You can use this function also to find only the user that
# has upload the image (FixME: Rewrite a bit this part)
@@ -637,7 +637,7 @@
except wikipedia.NoPage:
second_text = False
ti_es_ti = wikipedia.translate(self.site, empty)
- testoattuale = ti_es_ti
+ testoattuale = ti_es_ti
for i in self.botolist:
if latest_user == i:
second_text = True
@@ -666,7 +666,7 @@
text_to_send = re.sub(r'__user-nickname__', '%s' %
self.luser, emailText)
emailClass = EmailSender(self.site, self.luser)
emailClass.send(emailSubj, text_to_send)
-
+
def untaggedGenerator(self, untaggedProject, limit):
""" Generator that yield the images without license. It's
based on a tool of the toolserver. """
lang = untaggedProject.split('.', 1)[0]
@@ -674,7 +674,7 @@
if lang == 'commons':
link =
'http://toolserver.org/~daniel/WikiSense/UntaggedImages.php?wikifam=commons.wikimedia.org&since=-100d&until=&img_user_text=&order=img_timestamp&max=100&order=img_timestamp&format=html'
else:
- link =
'http://toolserver.org/~daniel/WikiSense/UntaggedImages.php?wikilang=%s&wikifam=%s&order=img_timestamp&max=%s&ofs=0&max=%s'
% (lang, project, limit, limit)
+ link =
'http://toolserver.org/~daniel/WikiSense/UntaggedImages.php?wikilang=%s&wikifam=%s&order=img_timestamp&max=%s&ofs=0&max=%s'
% (lang, project, limit, limit)
text = self.site.getUrl(link, no_hostname = True)
regexp = r"""<td valign='top'
title='Name'><a
href='http://.*?\.org/w/index\.php\?title=(.*?)'>.*?</a>&l…
results = re.findall(regexp, text)
@@ -685,7 +685,7 @@
for result in results:
wikiPage = wikipedia.Page(self.site, result)
yield wikiPage
-
+
def regexGenerator(self, regexp, textrun):
""" Generator used when an user use a regex parsing a page to
yield the results """
pos = 0
@@ -710,7 +710,7 @@
self.hiddentemplate.append('%s' % langK)
# The template #if: and #switch: aren't something to care about
self.hiddentemplate.extend(['#if:', '#switch:'])
- # Hidden template loading
+ # Hidden template loading
if self.pageHidden != None:
try:
pageHiddenText = wikipedia.Page(self.site, self.pageHidden).get()
@@ -777,7 +777,7 @@
elif 'stemma' in self.image.lower() and self.site.lang ==
'it':
wikipedia.output(u'%s has "stemma" inside, means that
it\'s ok.' % self.image)
return True # Problems? No, it's only not on commons but the image
needs a check
- else:
+ else:
repme = "\n*[[:Image:%s]] is also on
'''Commons''': [[commons:Image:%s]]" % (self.image,
commons_image_with_this_hash[0])
self.report_image(self.image, self.rep_page,
self.com, repme, addings =
False, regex = regexOnCommons)
# Problems? No, return True
@@ -811,7 +811,7 @@
for duplicate in duplicates:
if self.convert_to_url(duplicate) ==
self.convert_to_url(self.image):
continue # the image itself, not report also this as duplicate
- repme += "\n**[[:Image:%s]]" %
self.convert_to_url(duplicate)
+ repme += "\n**[[:Image:%s]]" %
self.convert_to_url(duplicate)
result = self.report_image(self.image, self.rep_page,
self.com, repme,
addings = False, regex = duplicateRegex)
if not result:
return True # If Errors, exit (but continue the check)
@@ -831,7 +831,7 @@
Page_oder_image = wikipedia.ImagePage(self.site, u'Image:%s' %
older_image)
string = ''
images_to_tag_list = []
- for duplicate in duplicates:
+ for duplicate in duplicates:
if wikipedia.ImagePage(self.site, u'%s:%s' %
(self.image_namespace, duplicate)) == \
wikipedia.ImagePage(self.site, u'%s:%s' %
(self.image_namespace, older_image)):
continue # the older image, not report also this as duplicate
@@ -856,14 +856,14 @@
for image_to_tag in images_to_tag_list[:-1]:
self.report(re.sub(r'__image__', r'%s' %
older_image_ns, dupText), image_to_tag,
commImage = dupComment_image, unver = True)
- if len(images_to_tag_list) != 0:
+ if len(images_to_tag_list) != 0:
self.report(re.sub(r'__image__', r'%s' %
older_image_ns, dupText), images_to_tag_list[-1],
dupTalkText % (older_image_ns, string), dupTalkHead, commTalk =
dupComment_talk,
commImage = dupComment_image, unver = True)
if older_image != self.image:
return False # The image is a duplicate, it will be deleted.
return True # Ok - No problem. Let's continue the checking phase
-
+
def report_image(self, image_to_report, rep_page = None, com = None, rep_text = None,
addings = True, regex = None):
""" Function to report the images in the report page when needed.
"""
if rep_page == None: rep_page = self.rep_page
@@ -876,7 +876,7 @@
else:
text_get = str()
if len(text_get) >= self.logFulNumber:
- raise LogIsFull("The log page (%s) is full! Please delete the old images
reported." % another_page.title())
+ raise LogIsFull("The log page (%s) is full! Please delete the old images
reported." % another_page.title())
pos = 0
# The talk page includes "_" between the two names, in this way i
replace them to " "
n = re.compile(regex, re.UNICODE|re.M)
@@ -884,7 +884,7 @@
if y == None:
# Adding the log
if addings:
- rep_text = rep_text % image_to_report # Adding the name of the image in
the report if not done already
+ rep_text = rep_text % image_to_report # Adding the name of the image in
the report if not done already
another_page.put(text_get + rep_text, comment = com, minorEdit = False)
wikipedia.output(u"...Reported...")
reported = True
@@ -893,7 +893,7 @@
wikipedia.output(u"%s is already in the report page." %
image_to_report)
reported = False
return reported
-
+
def takesettings(self):
""" Function to take the settings from the wiki.
"""
if self.settings == None: lista = None
@@ -919,7 +919,7 @@
number += 1
if lista == list():
wikipedia.output(u"You've set wrongly your settings, please
take a look to the relative page. (run without them)")
- lista = None
+ lista = None
except wikipedia.NoPage:
wikipedia.output(u"The settings' page doesn't exist!")
lista = None
@@ -939,7 +939,7 @@
pages = [page for page in gen]
list_licenses.extend(pages)
return list_licenses
-
+
def load(self, raw):
""" Load a list of object from a string using regex.
"""
list_loaded = list()
@@ -954,7 +954,7 @@
if word not in list_loaded:
list_loaded.append(word)
return list_loaded
-
+
def checkbot():
""" Main function """
# Command line configurable parameters
@@ -973,7 +973,7 @@
duplicatesReport = False # Use the duplicate-report option
sendemailActive = False # Use the send-email
smartdetection = False # Enable the smart detection
-
+
# Here below there are the parameters.
for arg in wikipedia.handleArgs():
if arg.startswith('-limit'):
@@ -995,9 +995,9 @@
elif arg == '-duplicatereport':
duplicatesReport = True
elif arg == '-sendemail':
- sendemailActive = True
+ sendemailActive = True
elif arg == '-smartdetection':
- smartdetection = True
+ smartdetection = True
elif arg.startswith('-skip'):
if len(arg) == 5:
skip = True
@@ -1057,21 +1057,21 @@
generator =
pagegenerators.ReferringPageGenerator(wikipedia.Page(wikipedia.getSite(), refName))
repeat = False
elif arg.startswith('-untagged'):
- untagged = True
+ untagged = True
if len(arg) == 9:
projectUntagged = str(wikipedia.input(u'In which project should I
work?'))
elif len(arg) > 9:
- projectUntagged = str(arg[10:])
-
+ projectUntagged = str(arg[10:])
+
# Understand if the generator it's the default or not.
try:
generator
except NameError:
normal = True
-
+
# Define the site.
site = wikipedia.getSite()
-
+
# Block of text to translate the parameters set above.
image_n = site.image_namespace()
image_namespace = "%s:" % image_n # Example: "User_talk:"
@@ -1084,7 +1084,7 @@
dels = wikipedia.translate(site, del_comm)
smwl = wikipedia.translate(site, second_message_without_license)
TextFind = wikipedia.translate(site, txt_find)
-
+
# If the images to skip are 0, set the skip variable to False (the same for the wait
time)
if skip_number == 0:
skip = False
@@ -1106,7 +1106,7 @@
# Some formatting for delete immediately template
di = '\n%s' % di
dels = dels % di
-
+
# Reading the log of the new images if another generator is not given.
if normal == True:
if limit == 1:
@@ -1163,7 +1163,7 @@
HiddenTN = wikipedia.translate(site, HiddenTemplateNotification)
# Not the main, but the most important loop.
#parsed = False
- for image in generator:
+ for image in generator:
# When you've a lot of image to skip before working use this workaround,
otherwise
# let this commented, thanks. [ decoment also parsed = False if you want to
use it
#
@@ -1172,7 +1172,7 @@
# continue
#else:
# parsed = True
-
+
# If I don't inizialize the generator, wait part and skip part are
useless
if wait:
printWithTimeZone(u'Waiting %s seconds before checking the
images,' % wait_number)
@@ -1208,11 +1208,11 @@
skip_list.append(imageName)
if skip_number == 1:
wikipedia.output('')
- skip = False
+ skip = False
continue
else:
wikipedia.output('') # Print a blank line.
- skip = False
+ skip = False
elif skip_list == []: # Skip must be false if we are here but
# the user has set 0 as images to skip
wikipedia.output(u'\t\t>> No images to skip...<<')
@@ -1241,7 +1241,7 @@
if duplicatesActive == True:
response2 = mainClass.checkImageDuplicated()
if response2 == False:
- continue
+ continue
# Is the image already tagged? If yes, no need to double-check, skip
for i in TextFind:
# If there are {{ use regex, otherwise no (if there's not the {{ may
not be a template
@@ -1272,7 +1272,7 @@
elif white_template_found == 0:
pass # if nothing found, print nothing
else:
- wikipedia.output(u'White templates found: %s; skipping those
templates...' % white_template_found)
+ wikipedia.output(u'White templates found: %s; skipping those
templates...' % white_template_found)
for a_word in something: # something is the array with {{, MIT License and so
on.
if a_word in g:
# There's a template, probably a license (or I hope so)
@@ -1315,7 +1315,7 @@
imagestatus_used = imagestatus
name_used = name
summary_used = summary
- mex_used = mexCatched
+ mex_used = mexCatched
break
elif find_tipe.lower() == 'find':
if k.lower() in g.lower():
@@ -1356,12 +1356,12 @@
elif parentesi == True:
seems_ok = False
license_found = None
- if smartdetection:
+ if smartdetection:
regex_find_licenses =
re.compile(r'\{\{(?:[Tt]emplate:|)(.*?)(?:[|\n].*?|)\}\}', re.DOTALL)
licenses_found = regex_find_licenses.findall(g)
- if licenses_found != []:
+ if licenses_found != []:
for license_selected in licenses_found:
- #print template.exists()
+ #print template.exists()
template = wikipedia.Page(site, 'Template:%s' %
license_selected)
try:
if template.isRedirectPage():
@@ -1385,9 +1385,9 @@
if license_found != None:
printWithTimeZone(u"%s seems ok, license found:
%s..." % (imageName, license_found))
else:
- printWithTimeZone(u"%s seems ok..." % imageName)
+ printWithTimeZone(u"%s seems ok..." % imageName)
# It works also without this... but i want only to be sure ^^
- parentesi = False
+ parentesi = False
continue
elif delete == True:
wikipedia.output(u"%s is not a file!" % imageName)
@@ -1405,7 +1405,7 @@
notification = HiddenTN % imageName
else:
notification = nn % imageName
- head = nh
+ head = nh
mainClass.report(unvertext, imageName, notification, head, smwl)
continue
else:
@@ -1424,7 +1424,7 @@
elif repeat == False:
wikipedia.output(u"\t\t\t>> STOP! <<")
return True # Exit
-
+
# Here there is the main loop. I'll take all the (name of the) images and then
i'll check them.
if __name__ == "__main__":
try:
Modified: trunk/pywikipedia/clean_sandbox.py
===================================================================
--- trunk/pywikipedia/clean_sandbox.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/clean_sandbox.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -85,7 +85,7 @@
'pl': u'Wikipedia:Brudnopis',
'pt': u'Wikipedia:Página de testes',
'commons': u'Commons:Sandbox',
- 'sr': u'Википедија:Песак',
+ 'sr': u'Википедија:Песак',
'sv': u'Wikipedia:Sandlådan',
'th': u'วิกิพีเดีย:ทดลองเขียน',
'zh': u'wikipedia:沙盒',
Modified: trunk/pywikipedia/commons_category_redirect.py
===================================================================
--- trunk/pywikipedia/commons_category_redirect.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/commons_category_redirect.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -12,6 +12,7 @@
#
# Distributed under the terms of the MIT license.
#
+__version__ = '$Id$'
import wikipedia, config, catlib
from category import *
@@ -36,7 +37,7 @@
if not destination.exists():
return None
return destination
-
+
def readyToEdit(old_category):
'''
If the category is edited more recenty than cooldown, return false, otherwise true.
@@ -50,13 +51,13 @@
def main():
'''
Main loop. Loop over all categories of Category:Non-empty_category_redirects and move
all content.
- '''
+ '''
site = wikipedia.getSite(u'commons', u'commons')
dirtycat = catlib.Category(site, u'Category:Non-empty category redirects')
destination = None
catbot = None
-
+
for old_category in dirtycat.subcategories():
#We want to wait several days after the last edit before we start moving things
around.
#This it to prevent edit wars and vandals.
@@ -65,12 +66,12 @@
if destination:
wikipedia.output(destination.title())
for page in old_category.articles():
- try:
+ try:
catlib.change_category(page, old_category, destination,
move_message % (old_category.title(), old_category.titleWithoutNamespace(),
destination.title(), destination.titleWithoutNamespace()))
except wikipedia.IsRedirectPage:
wikipedia.output(page.title() + u' is a redirect!')
for cat in old_category.subcategories():
- try:
+ try:
catlib.change_category(cat, old_category, destination,
move_message % (old_category.title(), old_category.titleWithoutNamespace(),
destination.title(), destination.titleWithoutNamespace()))
except wikipedia.IsRedirectPage:
wikipedia.output(page.title() + u' is a redirect!')
@@ -78,7 +79,7 @@
try:
old_category.put(old_category.get())
except:
- wikipedia.output(u'Dummy edit at ' + old_category.title() +
u' failed')
+ wikipedia.output(u'Dummy edit at ' + old_category.title() +
u' failed')
if __name__ == "__main__":
try:
Property changes on: trunk/pywikipedia/commons_category_redirect.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/commonscat.py
===================================================================
--- trunk/pywikipedia/commonscat.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/commonscat.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -32,6 +32,7 @@
#
# Distributed under the terms of the MIT license.
#
+__version__ = '$Id$'
import wikipedia, config, pagegenerators, add_text
@@ -152,8 +153,8 @@
'zh-yue' : u'同享類',
}
-ignoreTemplates = {
- 'ar' : [u'تحويلة تصنيف', u'كومنز', u'كومونز',
u'Commonscat'],
+ignoreTemplates = {
+ 'ar' : [u'تحويلة تصنيف', u'كومنز', u'كومونز',
u'Commonscat'],
'en' : [u'Category redirect', u'Commons',
u'Commonscat', u'Commonscat1A', u'Commoncats',
u'Commonscat4Ra', u'Sisterlinks', u'Sisterlinkswp', u'Tracking
category', u'Template category', u'Wikipedia category'],
'it' : [(u'Ip', 'commons='), ('Interprogetto',
'commons=')],
'ja' : [u'CommonscatS'],
@@ -183,8 +184,8 @@
else:
for (inPageTemplate, param) in templatesWithParams:
if inPageTemplate == template[0] and template[1] in param[0]:
- return True
- return False
+ return True
+ return False
def updateInterwiki (wikipediaPage = None, commonsPage = None):
'''
@@ -202,15 +203,15 @@
interwikis[interwikiPage.site()]=interwikiPage
oldtext = commonsPage.get()
# The commonssite object doesnt work with interwiki's
- newtext = wikipedia.replaceLanguageLinks(oldtext, interwikis,
wikipedia.getSite(u'nl'))
- comment = u'Updating interwiki\'s from [[' +
wikipediaPage.site().language() + u':' + wikipediaPage.title() + u']]'
+ newtext = wikipedia.replaceLanguageLinks(oldtext, interwikis,
wikipedia.getSite(u'nl'))
+ comment = u'Updating interwiki\'s from [[' +
wikipediaPage.site().language() + u':' + wikipediaPage.title() + u']]'
if newtext != oldtext:
#This doesnt seem to work. Newtext has some trailing whitespace
wikipedia.showDiff(oldtext, newtext)
commonsPage.put(newtext=newtext, comment=comment)
-
+
def addCommonscat (page = None, summary = None, always = False):
'''
Take a page. Go to all the interwiki page looking for a commonscat template.
@@ -219,7 +220,7 @@
commonscat = ""
commonscatpage = None
commonscats = []
-
+
wikipedia.output("Working on " + page.title());
if getTemplate(page.site().language()) in page.templates():
wikipedia.output("Commonscat template is already on " + page.title());
@@ -230,7 +231,7 @@
# updateInterwiki (page, commonscatpage)
# #Should remove the template if something is wrong
elif skipPage(page):
- wikipedia.output("Found a template in the skip list. Skipping " +
page.title());
+ wikipedia.output("Found a template in the skip list. Skipping " +
page.title());
else:
#Follow the interwiki's
for ipage in page.interwiki():
@@ -251,7 +252,7 @@
commonscatpage = commonscats.pop();
commonscat = commonscatpage.titleWithoutNamespace()
#We found one or more commonscat links, build the template and add it to our
page
- #TODO: We should check if we found more than one different link.
+ #TODO: We should check if we found more than one different link.
commonscat = "{{" + getTemplate(page.site().language()) +
"|" + commonscat + "}}";
(success, always) = add_text.add_text(page, commonscat, summary, None, None,
always);
#updateInterwiki(page, commonscatpage)
@@ -279,7 +280,7 @@
#wikipedia.output("getCommonscat : The category is a category
redirect");
for template in result.templatesWithParams():
if ((template[0]=="Category redirect") and (len(template[1]) >
0)):
- return getCommonscat(template[1][0])
+ return getCommonscat(template[1][0])
elif result.isDisambig():
#wikipedia.output("getCommonscat : The category is disambigu");
return None
@@ -315,8 +316,8 @@
pregenerator = pagegenerators.PreloadingGenerator(generator)
- for page in pregenerator:
- (status, always) = addCommonscat(page, summary, always)
+ for page in pregenerator:
+ (status, always) = addCommonscat(page, summary, always)
if __name__ == "__main__":
try:
Property changes on: trunk/pywikipedia/commonscat.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/copyright_clean.py
===================================================================
--- trunk/pywikipedia/copyright_clean.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/copyright_clean.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
"""
"""
+__version__ = '$Id$'
#
# (C) Francesco Cosoleto, 2006
Property changes on: trunk/pywikipedia/copyright_clean.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/copyright_put.py
===================================================================
--- trunk/pywikipedia/copyright_put.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/copyright_put.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
"""
"""
+__version__ = '$Id$'
#
# (C) Francesco Cosoleto, 2006
Property changes on: trunk/pywikipedia/copyright_put.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/daemonize.py
===================================================================
--- trunk/pywikipedia/daemonize.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/daemonize.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,6 +1,6 @@
import sys, os
-__version__ = '$Id: $'
+__version__ = '$Id$'
is_daemon = False
@@ -8,25 +8,25 @@
""" Daemonize the current process. Only works on POSIX compatible
operating
systems. The process will fork to the background and return control to
the terminal.
-
+
Arguments:
- close_fd: Close the standard streams and replace them by /dev/null
- chdir: Change the current working directory to /
- write_pid: Write the pid to sys.argv[0] + '.pid'
- redirect_std: Filename to redirect stdout and stdin to
"""
-
+
# Fork away
if not os.fork():
- # Become session leader
+ # Become session leader
os.setsid()
- # Fork again to prevent the process from acquiring a
+ # Fork again to prevent the process from acquiring a
# controlling terminal
pid = os.fork()
if not pid:
global is_daemon
is_daemon = True
-
+
if close_fd:
os.close(0)
os.close(1)
Property changes on: trunk/pywikipedia/daemonize.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/date.py
===================================================================
--- trunk/pywikipedia/date.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/date.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -94,7 +94,7 @@
if pred(value):
return func(value)
- raise ValueError("could not find a matching function")
+ raise ValueError("could not find a matching function")
#
@@ -145,9 +145,9 @@
return dh_noConv( value, pattern, formatLimits['MillenniumAD'][0] )
def dh_millenniumBC( value, pattern ):
return dh_noConv( value, pattern, formatLimits['MillenniumBC'][0] )
-
-
+
+
def decSinglVal( v ):
return v[0]
@@ -178,7 +178,7 @@
def dh_singVal( value, match ):
return dh_constVal( value, 0, match )
-
+
def dh_constVal( value, ind, match ):
"""This function helps with matching a single value to a constant.
formats['CurrEvents']['en'](ind) => u'Current
Events'
@@ -248,12 +248,12 @@
'X', 'XI', 'XII', 'XIII', 'XIV',
'XV', 'XVI', 'XVII', 'XVIII', 'XIX',
'XX', 'XXI', 'XXII', 'XXIII',
'XXIV', 'XXV', 'XXVI', 'XXVII', 'XXVIII',
'XXVIX',
'XXX']
-
+
def intToRomanNum(i):
if i >= len(_romanNumbers):
raise IndexError(u'Roman value %i is not defined' % i)
return _romanNumbers[i]
-
+
def romanNumToInt(v):
return _romanNumbers.index(v)
@@ -268,13 +268,13 @@
# %K is a number in KN::
'K' : ( _knDigits, lambda v: intToLocalDigitsStr(v, _knDigitsToLocal), lambda
v: localDigitsStrToInt(v, _knDigitsToLocal, _knLocalToDigits) ),
# %F is a number in FA:
- 'F' : ( _faDigits, lambda v: intToLocalDigitsStr(v, _faDigitsToLocal), lambda
v: localDigitsStrToInt(v, _faDigitsToLocal, _faLocalToDigits) ),
+ 'F' : ( _faDigits, lambda v: intToLocalDigitsStr(v, _faDigitsToLocal), lambda
v: localDigitsStrToInt(v, _faDigitsToLocal, _faLocalToDigits) ),
# %H is a number in HI:
- 'H' : ( _hiDigits, lambda v: intToLocalDigitsStr(v, _hiDigitsToLocal), lambda
v: localDigitsStrToInt(v, _hiDigitsToLocal, _hiLocalToDigits) ),
+ 'H' : ( _hiDigits, lambda v: intToLocalDigitsStr(v, _hiDigitsToLocal), lambda
v: localDigitsStrToInt(v, _hiDigitsToLocal, _hiLocalToDigits) ),
# %B is a number in BN:
- 'B' : ( _bnDigits, lambda v: intToLocalDigitsStr(v, _bnDigitsToLocal), lambda
v: localDigitsStrToInt(v, _bnDigitsToLocal, _bnLocalToDigits) ),
+ 'B' : ( _bnDigits, lambda v: intToLocalDigitsStr(v, _bnDigitsToLocal), lambda
v: localDigitsStrToInt(v, _bnDigitsToLocal, _bnLocalToDigits) ),
# %G is a number in GU:
- 'G' : ( _guDigits, lambda v: intToLocalDigitsStr(v, _guDigitsToLocal), lambda
v: localDigitsStrToInt(v, _guDigitsToLocal, _guLocalToDigits) ),
+ 'G' : ( _guDigits, lambda v: intToLocalDigitsStr(v, _guDigitsToLocal), lambda
v: localDigitsStrToInt(v, _guDigitsToLocal, _guLocalToDigits) ),
# %T is a year in TH: -- all years are shifted: 2005 => 'พ.ศ. 2548'
'T' : ( _decimalDigits, lambda v: unicode(v+543), lambda v: int(v)-543 ),
}
@@ -321,7 +321,7 @@
else:
newPattern += re.escape( s )
strPattern += s
-
+
newPattern += u'$' # end of the string
compiledPattern = re.compile( newPattern )
_escPtrnCache2[pattern] = (compiledPattern, strPattern, decoders)
@@ -343,7 +343,7 @@
decodingFunc:
Converts a tuple/list of non-negative integers found in the original value
string
- into a normalized value. The normalized value can be passed right back into
dh()
+ into a normalized value. The normalized value can be passed right back into
dh()
to produce the original string. This function is a complement of
encodingFunc.
dh() interprets %d as a decimal and %s as a roman numeral number.
"""
@@ -359,7 +359,7 @@
if decValue in _stringTypes:
raise AssertionError("Decoder must not return a string!")
-
+
# recursive call to re-encode and see if we get the original (may through
filter exception)
if value == dh(decValue, pattern, encf, decf, filter):
return decValue
@@ -370,9 +370,9 @@
# This will be called from outside as well as recursivelly to verify parsed
value
if filter and not filter(value):
raise ValueError("value %i is not allowed" % value)
-
+
params = encf(value)
-
+
if type(params) in _listTypes:
if len(params) != len(decoders):
raise AssertionError("parameter count (%d) does not match decoder
count (%d)" % (len(params), len(decoders)))
@@ -384,7 +384,7 @@
raise AssertionError("A single parameter does not match %d
decoders." % len(decoders))
# convert integer parameter into its textual representation
return strPattern % MakeParameter(decoders[0], params)
-
+
def MakeParameter( decoder, param ):
newValue = decoder[1](param)
if len(decoder) == 4 and len(newValue) < decoder[3]:
@@ -730,7 +730,7 @@
'eo' : lambda v: dh_decAD( v, u'%d-aj jaroj' ),
'es' : lambda v: dh_decAD( v, u'Años %d' ),
'et' : lambda v: dh_decAD( v, u'%d. aastad' ),
-
+
# decades ending in 00 are spelled differently
'fi' : lambda m: multi( m, [
(lambda v: dh_constVal( v, 0, u'Ensimmäinen vuosikymmen'), lambda p:
p == 0),
@@ -746,7 +746,7 @@
(lambda v: dh_decAD( v, u'%dth decade' ), alwaysTrue)]), #
********** ERROR!!!
'hi' : lambda v: dh_decAD( v, u'%H का दशक' ),
-
+
#1970s => 1970-1979
'hr' : lambda m: multi( m, [
(lambda v: dh_constVal( v, 1, u'1-9'),
lambda p: p == 1),
@@ -782,7 +782,7 @@
(lambda v: dh_constVal( v, 1, u'1-9'),
lambda p: p == 1),
(lambda v: dh( v, u'%d-%d', lambda i: (encDec0(i),encDec0(i)+9),
decSinglVal ), alwaysTrue)]),
- 'nn' : lambda v: dh_decAD( v, u'%d0-åra' ), # FIXME: not
sure of this one
+ 'nn' : lambda v: dh_decAD( v, u'%d0-åra' ), # FIXME: not
sure of this one
'no' : lambda v: dh_decAD( v, u'%d-årene' ),
'os' : lambda v: dh_decAD( v, u'%d-тæ' ),
@@ -801,7 +801,7 @@
'ru' : lambda v: dh_decAD( v, u'%d-е' ),
'scn': lambda v: dh_decAD( v, u'%dini' ),
'simple' : lambda v: dh_decAD( v, u'%ds' ),
-
+
# 1970 => '70. roky 20. storočia'
'sk' : lambda v: dh( v, u'%d. roky %d. storočia',
lambda i: (encDec0(i)%100, encDec0(i)/100+1),
@@ -963,7 +963,7 @@
'mi' : lambda v: dh_centuryAD( v, u'Tua %d rau tau' ),
'mk' : lambda v: dh_centuryAD( v, u'%d век' ),
'nds': lambda v: dh_centuryAD( v, u'%d. Johrhunnert' ),
- 'nl' : lambda v: dh_centuryAD( v, u'%de eeuw' ),
+ 'nl' : lambda v: dh_centuryAD( v, u'%de eeuw' ),
'nn' : lambda m: multi( m, [
(lambda v: dh_constVal( v, 1, u'1. århundret'),
lambda p: p == 1),
(lambda v: dh( v, u'%d00-talet', lambda i: i-1, lambda ii: ii[0]+1 ),
alwaysTrue)]),
@@ -1024,7 +1024,7 @@
(lambda v: dh( v, u'%d00-luku eaa.', lambda i: i-1, lambda ii:
ii[0]+1 ), alwaysTrue)]),
'fr' : lambda m: multi( m, [
(lambda v: dh_centuryBC( v, u'%Rer siècle av. J.-C.' ), lambda
p: p == 1),
- (lambda v: dh_centuryBC( v, u'%Re siècle av. J.-C.' ),
alwaysTrue)]),
+ (lambda v: dh_centuryBC( v, u'%Re siècle av. J.-C.' ),
alwaysTrue)]),
'he' : lambda v: dh_centuryBC( v, u'המאה ה־%d לפני הספירה'
),
'hr' : lambda v: dh_centuryBC( v, u'%d. stoljeće p.n.e.' ),
'id' : lambda v: dh_centuryBC( v, u'Abad ke-%d SM' ),
@@ -1064,12 +1064,12 @@
'da' : lambda v: dh_centuryAD( v, u'%d. århundrede' ),
'no' : lambda v: dh( v, u'%d-tallet', lambda i: (i-1)*100,
lambda ii: ii[0]/100+1 ),
},
-
+
'CenturyBC_Cat':{
'de' : lambda v: dh_centuryBC( v, u'Jahr (%d. Jh. v. Chr.)'
),
'no' : lambda v: dh( v, u'%d-tallet f.Kr.', lambda i:
(i-1)*100, lambda ii: ii[0]/100+1 ),
},
-
+
'MillenniumAD': {
'bg' : lambda v: dh_millenniumAD( v, u'%d хилядолетие' ),
'ca' : lambda v: dh_millenniumAD( v, u'Mil·lenni %R' ),
@@ -1542,7 +1542,7 @@
>> date.testMapEntry( 'DecadeAD', 1992,
1990 )
>> date.testMapEntry( 'CenturyAD', 20, 20 )
"""
-
+
step = 1
if formatName in decadeFormats: step = 10
predicate,start,stop = formatLimits[formatName]
@@ -1550,7 +1550,7 @@
start, stop = value, value+1
if showAll:
wikipedia.output(u"Processing %s with limits from %d to %d and step %d"
% (formatName, start,stop-1,step))
-
+
for code, convFunc in formats[formatName].iteritems():
# import time
# startClock = time.clock()
@@ -1576,13 +1576,13 @@
>> date.test()
"""
for formatName in formats.keys():
-
+
if quick:
testMapEntry( formatName, showAll, formatLimits[formatName][1] ) # Only
test the first value in the test range
else:
testMapEntry( formatName, showAll ) # Extensive test! # Test
decade rounding
wikipedia.output(u"'%s' complete." % formatName)
-
+
if quick:
#wikipedia.output(u'Date module quick consistency test passed')
pass
Modified: trunk/pywikipedia/delinker.py
===================================================================
--- trunk/pywikipedia/delinker.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/delinker.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,6 +1,6 @@
# Helper script for delinker and image_replacer
-__version__ = '$Id: $'
+__version__ = '$Id$'
import wikipedia, config
Property changes on: trunk/pywikipedia/delinker.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/diskcache.py
===================================================================
--- trunk/pywikipedia/diskcache.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/diskcache.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,3 +1,5 @@
+__version__ = '$Id$'
+
import random
import config
import sys
@@ -19,11 +21,11 @@
self.max_size = max_size
while True:
self.cache_path = config.datafilepath(cache_base, prefix + ''.join(
- [random.choice('abcdefghijklmnopqrstuvwxyz')
+ [random.choice('abcdefghijklmnopqrstuvwxyz')
for i in xrange(16)]))
if not os.path.exists(self.cache_path): break
self.cache_file = open(self.cache_path, 'wb+')
-
+
lookup = [-1] * 36
data.sort(key = lambda i: i[0])
for key, value in data:
@@ -35,62 +37,62 @@
index = key[0]
if not ((index >= 'a' and index <= 'z') or (index >=
'0' and index <= '9')) or '\t' in key:
raise RuntimeError('Only alphabetic keys are supported', key)
-
+
if index < 'a':
index = ord(index) - 48 + 26 # Numeric
else:
index = ord(index) - 97
if lookup[index] == -1:
lookup[index] = self.cache_file.tell()
-
+
if type(value) is unicode:
value = value.encode('utf-8')
elif type(value) != str:
value = str(value)
-
+
if len(key) > 0xFF:
raise RuntimeError('Key length must be smaller than %i' % 0xFF)
if len(value) > 0xFFFFFF:
raise RuntimeError('Value length must be smaller than %i' %
0xFFFFFF)
-
+
self.cache_file.write('%02x%s%06x%s' % (len(key), key, len(value),
value))
-
+
self.lookup = lookup
self.cache_file.seek(0)
self.cache = []
-
+
def delete(self):
self.cache_file.close()
import os
os.unlink(self.cache_path)
os = None
-
+
def __getitem__(self, key):
key = key.lower()
if type(key) is unicode:
key = key.encode('utf-8')
-
+
try:
index = key[0]
except IndexError:
raise KeyError(key)
if not ((index >= 'a' and index <= 'z') or (index >=
'0' and index <= '9')):
raise KeyError(key)
-
+
if index < 'a':
if index < '0' or index > '9':
raise KeyError(key)
i = ord(index) - 48 + 26 # Numeric
else:
- if index > 'z':
+ if index > 'z':
raise KeyError(key)
i = ord(index) - 97
-
+
for k, v in self.cache:
if k == key:
self.cache.remove((k, v))
self.cache.append((k, v))
-
+
self.cache_file.seek(self.lookup[i])
while True:
length = int(self.read(2, key), 16)
@@ -102,14 +104,14 @@
del self.cache[0]
self.cache.append((key, value))
return value
-
+
elif k[0] != index:
raise KeyError(key)
-
+
length = int(self.read(6, key), 16)
self.cache_file.seek(length, os.SEEK_CUR)
-
-
+
+
def read(self, length, key = ''):
s = self.cache_file.read(length)
if not s: raise KeyError(key)
Property changes on: trunk/pywikipedia/diskcache.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/distrib
===================================================================
--- trunk/pywikipedia/distrib 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/distrib 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,4 +1,5 @@
#!/bin/sh
+# $Id$
dt=`date +"%Y%m%d"`
/bin/rm -rf temp
mkdir temp
Property changes on: trunk/pywikipedia/distrib
___________________________________________________________________
Name: svn:executable
- *
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/djvutext.py
===================================================================
--- trunk/pywikipedia/djvutext.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/djvutext.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -11,12 +11,12 @@
-ask Ask for confirmation before creating each page.
-index:... Name of the index page
-djvu:... Filename of the djvu file
- -pages:<start>-<end> Page range to upload; <end> is optional
+ -pages:<start>-<end> Page range to upload; <end> is optional
All other parameters will be regarded as part of the title of a single page,
and the bot will only work on that single page.
"""
-__version__ = '$Id: basic.py 5227 2008-04-17 09:37:15Z mfarag $'
+__version__ = '$Id$'
import wikipedia
import os
import config, codecs
Property changes on: trunk/pywikipedia/djvutext.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/editarticle.py
===================================================================
--- trunk/pywikipedia/editarticle.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/editarticle.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -92,9 +92,9 @@
Calls the editor and thus allows the user to change the text.
Returns the modified text. Halts the thread's operation until the editor
is closed.
-
+
Returns None if the user didn't save the text file in his text editor.
-
+
Parameters:
* text - a Unicode string
* jumpIndex - an integer: position at which to put the caret
@@ -159,7 +159,7 @@
fp.write(new)
fp.close()
wikipedia.output(u"An edit conflict has arisen. Your edit has been saved to
%s. Please try again." % fn)
-
+
def run(self):
try:
old = self.page.get(get_redirect = self.options.edit_redirect)
Modified: trunk/pywikipedia/extract_wikilinks.py
===================================================================
--- trunk/pywikipedia/extract_wikilinks.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/extract_wikilinks.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -22,7 +22,7 @@
__version__='$Id$'
#
import sys,re,wikipedia,codecs
-wikipedia.stopme() # This bot does not contact the Wiki, so no need to get it on the list
+wikipedia.stopme() # This bot does not contact the Wiki, so no need to get it on the
list
R = re.compile('/wiki/(.*?)" *')
fn = []
sorted = False
Modified: trunk/pywikipedia/family.py
===================================================================
--- trunk/pywikipedia/family.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/family.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -3200,11 +3200,11 @@
"""Returns a datetime object representing server
time"""
# TODO : If the local computer time is wrong, result wll be wrong
return datetime.utcnow() + self.servergmtoffset
-
+
def isPublic(self):
"""Does the wiki require logging in before viewing it
?"""
return True
-
+
def post_get_convert(self, site, getText):
"""Does a conversion on the retrieved text from the wiki
i.e. Esperanto X-conversion """
Property changes on: trunk/pywikipedia/featured.py
___________________________________________________________________
Name: svn:executable
- *
Modified: trunk/pywikipedia/featuredcount.py
===================================================================
--- trunk/pywikipedia/featuredcount.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/featuredcount.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -6,7 +6,7 @@
usage: featuredcount.py
"""
-__version__ = '$Id: featured.py 4811 2008-01-05 16:22:45Z leogregianin $'
+__version__ = '$Id$'
#
# Distributed under the terms of the MIT license.
@@ -28,7 +28,7 @@
elif p.namespace()==1:
arts.append(wikipedia.Page(p.site(), p.titleWithoutNamespace()))
wikipedia.output('\03{lightred}** wikipedia:%s has %i featured
articles\03{default}' % (site.lang, len(arts)))
-
+
if __name__=="__main__":
mysite = wikipedia.getSite()
fromlang = featured_name.keys()
Property changes on: trunk/pywikipedia/featuredcount.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/fixing_redirects.py
===================================================================
--- trunk/pywikipedia/fixing_redirects.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/fixing_redirects.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -17,7 +17,7 @@
#
# Distributed under the terms of the MIT license.
#
-__version__='$Id: disambredir.py 4407 2007-10-03 17:27:14Z leogregianin $'
+__version__='$Id$'
#
import wikipedia
import pagegenerators
@@ -67,7 +67,7 @@
"""
mysite = wikipedia.getSite()
linktrail = mysite.linktrail()
-
+
# make a backup of the original text so we can show the changes later
linkR =
re.compile(r'\[\[(?P<title>[^\]\|#]*)(?P<section>#[^\]\|]*)?(\|(?P<label>[^\]]*))?\]\](?P<linktrail>'
+ linktrail + ')')
curpos = 0
Property changes on: trunk/pywikipedia/fixing_redirects.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/followlive.py
===================================================================
--- trunk/pywikipedia/followlive.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/followlive.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -29,13 +29,13 @@
# templates that can be used followed by the message used as comment
# templates contains list of languages code
# languages code contains list of templates to be used
-# templates contains a message and its position
+# templates contains a message and its position
templates = {
'ar': {
'{{شطب}}' :{
'msg' : 'وسم مساعد بالبوت: هذا المقال ينبغي حذفه',
'pos': 'top'},
-
+
'{{تنظيف}}' :{
'msg' : 'وسم مساعد بالبوت: هذا المقال يحتاج للتنظيف',
'pos': 'top'},
@@ -52,7 +52,7 @@
'{{db-reason}}' :{
'msg' : 'Robot-assisted tagging: this article should be
deleted',
'pos': 'top'},
-
+
'{{cleanup}}' :{
'msg' : 'Robot-assisted tagging: this article need cleanup',
'pos': 'top'},
@@ -89,7 +89,7 @@
'{{Eliminar}}' :{
'msg' : 'Assistite per robot: iste articulo debe esser
eliminate',
'pos': 'top'},
-
+
'{{Revision}}' :{
'msg' : 'Assistite per robot: iste articulo require
revision',
'pos': 'top'},
@@ -198,7 +198,7 @@
u'{{wikificar}}' : {
'msg': 'Assistida por bot: {{wikificar}}',
'pos':'top'},
-
+
u'{{reciclar}}' : {
'msg': 'Assistida por bot: {{reciclar}}',
'pos':'top'},
@@ -223,7 +223,7 @@
u'{{radera}}' :{
'msg' : u'Robotkoll: Artikeln bör raderas',
'pos': 'top'},
-
+
u'{{städa}}' :{
'msg' : u'Robotkoll: Artikeln bör städas',
'pos': 'top'},
@@ -256,7 +256,7 @@
u'{{Delete}}' :{
'msg' : u'機器人掛上模板: 本文應被刪除。',
'pos': 'top'},
-
+
u'{{subst:Cleanup/auto}}' :{
'msg' : u'機器人掛上模板: 本文需清理',
'pos': 'top'},
@@ -301,11 +301,11 @@
'pos': 'top'},
u'{{subst:Translating/auto}}':{
'msg' : u'機器人掛上模板: 本条目没有翻译完成',
- 'pos': 'top'},
+ 'pos': 'top'},
u'{{fansite}}':{
'msg' : u'機器人掛上模板: 本条目內容類似愛好者網站',
- 'pos': 'top'},
-
+ 'pos': 'top'},
+
},
}
@@ -358,7 +358,7 @@
self.user = user
self.comment = comment
- # Display informations about an article
+ # Display informations about an article
def showpageinfo(self):
wikipedia.output(u'[[%s]] %s ' % (self.page.title(), self.date))
print 'Length: %i bytes' % self.length
@@ -463,7 +463,7 @@
print 'seems already gone'
print '----- Current time:', datetime.datetime.now()
-
+
class CleaningBot:
def __init__(self, site=None):
if site is None:
@@ -478,7 +478,7 @@
# Generate the question text
i = 0
questions = '\n'
-questionlist = {}
+questionlist = {}
for t in wikipedia.translate(wikipedia.getSite(), templates):
i+=1
questions += ( u'%s) %s\n' % (i,t) )
Property changes on: trunk/pywikipedia/followlive.py
___________________________________________________________________
Name: svn:executable
- *
Property changes on: trunk/pywikipedia/generate_user_files.py
___________________________________________________________________
Name: keywords
- Author Date Id Revision
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/gui.py
===================================================================
--- trunk/pywikipedia/gui.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/gui.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -226,7 +226,7 @@
self.editbox.pack(side=TOP)
self.editbox.add_bindings()
self.bind("<<open-config-dialog>>", self.config_dialog)
-
+
bottom = Frame(parent)
# lower left subframe which will contain a textfield and a Search button
bottom_left_frame = Frame(bottom)
@@ -253,7 +253,7 @@
# create a toplevel menu
menubar = Menu(self.parent)
-
+
findmenu = Menu(menubar)
findmenu.add_command(label="Find",
command=self.editbox.find_event,
@@ -304,7 +304,7 @@
command=self.config_dialog,
underline=0)
menubar.add_cascade(label="Options", menu=optmenu, underline=0)
-
+
# display the menu
self.parent.config(menu=menubar)
self.pack()
@@ -335,7 +335,7 @@
self.editbox.see('%d.%d' % (line, column))
# wait for user to push a button which will destroy (close) the window
self.parent.mainloop()
- return self.text
+ return self.text
def find_all(self, target):
self.textfield.insert(END, target)
@@ -356,7 +356,7 @@
self.text = self.editbox.get('1.0', END)
# if the editbox contains ASCII characters only, get() will
# return string, otherwise unicode (very annoying). We only want
- # it to return unicode, so we work around this.
+ # it to return unicode, so we work around this.
if isinstance(self.text, str):
self.text = unicode(self.text)
self.parent.destroy()
Modified: trunk/pywikipedia/imagecopy.py
===================================================================
--- trunk/pywikipedia/imagecopy.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/imagecopy.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -76,7 +76,7 @@
#
# Another rewrite by:
# (C) Multichill 2008
-#
+#
# Distributed under the terms of the MIT license.
#
__version__='$Id$'
@@ -149,7 +149,7 @@
'mn': u'{{NowCommons|Image:%s}}',
'ms': u'{{NowCommons|%s}}',
'nds-nl': u'{{NoenCommons|Image:%s}}',
- 'nl': u'{{NuCommons|%s}}',
+ 'nl': u'{{NuCommons|%s}}',
'nn': u'{{No på Commons|Image:%s}}',
'no': u'{{NowCommons|%s}}',
'oc': u'{{NowCommons|Image:%s}}',
@@ -290,7 +290,7 @@
for moveTemplate in
moveToCommonsTemplate[self.imagePage.site().language()]:
imtxt = re.sub(u'(?i)\{\{' + moveTemplate + u'\}\}',
u'', imtxt)
- #add {{NowCommons}}
+ #add {{NowCommons}}
if nowCommonsTemplate.has_key(self.imagePage.site().language()):
addTemplate = nowCommonsTemplate[self.imagePage.site().language()] %
self.newname.decode('utf-8')
else:
@@ -314,7 +314,7 @@
else:
moveSummary = imageMoveMessage['_default'] %
(self.imagePage.titleWithoutNamespace(), self.newname.decode('utf-8'))
imagebot = ImageRobot(generator = self.preloadingGen, oldImage =
self.imagePage.titleWithoutNamespace(), newImage = self.newname.decode('utf-8'),
summary = moveSummary, always = True, loose = True)
- imagebot.run()
+ imagebot.run()
return
#-label ok skip view
@@ -389,25 +389,25 @@
'''
self.changename=self.entry.get()
self.root.destroy()
-
+
def skipFile(self):
'''
The user pressed the Skip button.
'''
self.skip=1
self.root.destroy()
-
+
def openInBrowser(self):
'''
The user pressed the View in browser button.
'''
webbrowser.open(self.url)
-
+
def add2autoskip(self):
'''
The user pressed the Add to AutoSkip button.
'''
- templateid=int(self.templatelist.curselection()[0])
+ templateid=int(self.templatelist.curselection()[0])
template=self.templatelist.get(templateid)
toadd=codecs.open(archivo, 'a', 'utf-8')
toadd.write('{{'+template)
@@ -459,24 +459,24 @@
pregenerator = pagegenerators.PreloadingGenerator(generator)
- for page in pregenerator:
+ for page in pregenerator:
if page.exists() and (page.namespace() == 6) and (not page.isRedirectPage()) :
imagepage = wikipedia.ImagePage(page.site(), page.title())
- #First do autoskip.
+ #First do autoskip.
if doiskip(imagepage.get()):
wikipedia.output("Skipping " + page.title())
- skip = True
+ skip = True
else:
# The first upload is last in the list.
try:
- username = imagepage.getLatestUploader()[0]
+ username = imagepage.getLatestUploader()[0]
except NotImplementedError:
#No API, using the page file instead
(datetime, username, resolution, size, comment) =
imagepage.getFileVersionHistory().pop()
while True:
- # Do the Tkdialog to accept/reject and change te name
+ # Do the Tkdialog to accept/reject and change te name
(newname, skip)=Tkdialog(imagepage.titleWithoutNamespace(),
imagepage.get(), username, imagepage.permalink(), imagepage.templates()).getnewname()
if skip:
@@ -484,7 +484,7 @@
break
# Did we enter a new name?
- if len(newname)==0:
+ if len(newname)==0:
#Take the old name
newname=imagepage.titleWithoutNamespace()
@@ -501,11 +501,11 @@
if not skip:
imageTransfer(imagepage, newname).start()
- wikipedia.output(u'Still ' + str(threading.activeCount()) + u' active
threads, lets wait')
+ wikipedia.output(u'Still ' + str(threading.activeCount()) + u' active
threads, lets wait')
for openthread in threading.enumerate():
if openthread != threading.currentThread():
- openthread.join()
- wikipedia.output(u'All threads are done')
+ openthread.join()
+ wikipedia.output(u'All threads are done')
if __name__ == "__main__":
try:
Modified: trunk/pywikipedia/imagerecat.py
===================================================================
--- trunk/pywikipedia/imagerecat.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/imagerecat.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -6,6 +6,7 @@
It takes the suggestions and the current categories. Put the categories through some
filters and add the result
"""
+__version__ = '$Id$'
#
# (C) Multichill 2008
# (tkinter part loosely based on imagecopy.py)
@@ -30,11 +31,11 @@
global category_blacklist
global countries
- blacklistPage = wikipedia.Page(wikipedia.getSite(),
u'User:Multichill/Category_blacklist')
+ blacklistPage = wikipedia.Page(wikipedia.getSite(),
u'User:Multichill/Category_blacklist')
for cat in blacklistPage.linkedPages():
category_blacklist.append(cat.titleWithoutNamespace())
-
- countryPage = wikipedia.Page(wikipedia.getSite(),
u'User:Multichill/Countries')
+
+ countryPage = wikipedia.Page(wikipedia.getSite(),
u'User:Multichill/Countries')
for country in countryPage.linkedPages():
countries.append(country.titleWithoutNamespace())
return
@@ -76,7 +77,7 @@
def getCommonshelperCats(imagepage):
'''
- Get category suggestions from CommonSense. Parse them and return a list of
suggestions.
+ Get category suggestions from CommonSense. Parse them and return a list of
suggestions.
'''
result = []
parameters = urllib.urlencode({'i' :
imagepage.titleWithoutNamespace().encode('utf-8'), 'r' : 'on',
'go-clean' : 'Find+Categories', 'cl' : 'li'})
@@ -92,14 +93,14 @@
except IOError:
wikipedia.output(u'Got an IOError, let\'s try again')
except socket.timeout:
- wikipedia.output(u'Got a timeout, let\'s try again')
+ wikipedia.output(u'Got a timeout, let\'s try again')
if matches:
if(matches.group('catnum') > 0):
categories = matches.group('cats').splitlines()
for cat in categories:
result.append(cat.replace('_',' '))
-
+
return list(set(result))
@@ -153,14 +154,14 @@
for cat in categories:
if (cat.endswith(u'by country')):
listByCountry.append(cat)
-
+
#If cat contains 'by country' add it to the list
#If cat contains the name of a country add it to the list
else:
for country in countries:
if not(cat.find(country)==-1):
- listCountries.append(country)
-
+ listCountries.append(country)
+
if(len(listByCountry) > 0):
for bc in listByCountry:
category = catlib.Category(wikipedia.getSite(), u'Category:' + bc)
@@ -168,7 +169,7 @@
for country in listCountries:
if (subcategory.titleWithoutNamespace().endswith(country)):
result.append(subcategory.titleWithoutNamespace())
-
+
return list(set(result))
@@ -189,7 +190,7 @@
filterCategoriesRe = re.compile('\[\[Category:([^\]]*)\]\]')
result =
filterCategoriesRe.findall(filterCategoriesPage.read().decode('utf-8'))
#except:
-
+
return result
@@ -206,7 +207,7 @@
comment = u'Filtering categories'
else:
comment = u'Image is categorized by a bot using data from
[[Commons:Tools#CommonSense|CommonSense]]'
-
+
wikipedia.showDiff(imagepage.get(), newtext)
imagepage.put(newtext, comment)
return
@@ -215,12 +216,12 @@
def removeTemplates(oldtext = u''):
'''
Remove {{Uncategorized}} and {{Check categories}} templates
- '''
+ '''
result = u''
- result = re.sub(u'\{\{\s*([Uu]ncat(egori[sz]ed(
image)?)?|[Nn]ocat|[Nn]eedscategory)[^}]*\}\}', u'', oldtext)
+ result = re.sub(u'\{\{\s*([Uu]ncat(egori[sz]ed(
image)?)?|[Nn]ocat|[Nn]eedscategory)[^}]*\}\}', u'', oldtext)
result = re.sub(u'<!-- Remove this line once you have added categories
-->', u'', result)
result = re.sub(u'\{\{\s*[Cc]heck categories[^}]*\}\}', u'', result)
- return result
+ return result
def main(args):
@@ -248,9 +249,9 @@
initLists()
categorizeImages(generator, onlyfilter)
-
- wikipedia.output(u'All done')
+ wikipedia.output(u'All done')
+
if __name__ == "__main__":
try:
main(sys.argv[1:])
Property changes on: trunk/pywikipedia/imagerecat.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/imagetransfer.py
===================================================================
--- trunk/pywikipedia/imagetransfer.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/imagetransfer.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -161,7 +161,7 @@
new = '{{%s}}' % new
old = re.compile('{{%s}}' % old)
description = wikipedia.replaceExcept(description, old, new,
['comment', 'math', 'nowiki', 'pre'])
-
+
description = wikipedia.translate(self.targetSite, copy_message) %
(sourceSite, description)
description += '\n\n' + sourceImagePage.getFileVersionHistoryTable()
# add interwiki link
@@ -221,7 +221,7 @@
break
print "="*60
-
+
def run(self):
for page in self.generator:
if self.interwiki:
@@ -263,7 +263,7 @@
interwiki = False
targetLang = None
targetFamily = None
-
+
for arg in wikipedia.handleArgs():
if arg == '-interwiki':
interwiki = True
Modified: trunk/pywikipedia/imageuncat.py
===================================================================
--- trunk/pywikipedia/imageuncat.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/imageuncat.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -4,6 +4,7 @@
See imagerecat.py (still working on that one) to add these images to categories.
"""
+__version__ = '$Id$'
#
# (C) Multichill 2008
#
@@ -11,10 +12,10 @@
#
#
-import os, sys, re, codecs
-import wikipedia, config, pagegenerators, query
+import os, sys, re, codecs
+import wikipedia, config, pagegenerators, query
from datetime import datetime
-from datetime import timedelta
+from datetime import timedelta
#Probably unneeded because these are hidden categories. Have to figure it out.
ignoreCategories = [u'[[Category:CC-BY-SA-3.0]]',
@@ -49,7 +50,7 @@
u'Agência Brasil',
u'AgenciaCamaraBr',
u'AgenciaSenadoBr',
- u'Ak',
+ u'Ak',
u'AL2TB',
u'Alabordache',
u'Alexj2002C220PD',
@@ -1161,7 +1162,7 @@
'lelimit' :'5000',
'lestart' :yesterday.strftime(dateformat),
'leend' :today.strftime(dateformat)
- }
+ }
data = query.GetData(params, site, useAPI = True, encodeTitle = False)
try:
@@ -1171,7 +1172,7 @@
raise NoPage(u'API Error, nothing found in the APIs')
except KeyError:
raise NoPage(u'API Error, nothing found in the APIs')
-
+
return pagegenerators.PagesFromTitlesGenerator(result, site)
def isUncat(page):
@@ -1182,22 +1183,22 @@
If we found a template which is in the ignore list, skip the page.
'''
wikipedia.output(u'Working on '+ page.title())
-
+
for category in page.categories():
if category not in ignoreCategories:
wikipedia.output(u'Got category ' + category.title())
- return False
-
+ return False
+
for templateWithTrail in page.templates():
#Strip of trailing garbage
- template = templateWithTrail.rstrip('\n').rstrip()
+ template = templateWithTrail.rstrip('\n').rstrip()
if template in skipTemplates:
# Already tagged with a template, skip it
wikipedia.output(u'Already tagged, skip it')
return False
elif template in ignoreTemplates:
# template not relevant for categorization
- wikipedia.output(u'Ignore ' + template)
+ wikipedia.output(u'Ignore ' + template)
else:
wikipedia.output(u'Not ignoring ' + template)
return False
@@ -1206,9 +1207,9 @@
def addUncat(page):
'''
Add the uncat template to the page
- '''
+ '''
newtext = page.get() + puttext
- wikipedia.showDiff(page.get(), newtext)
+ wikipedia.showDiff(page.get(), newtext)
try:
page.put(newtext, putcomment)
except wikipedia.EditConflict:
@@ -1217,7 +1218,7 @@
except wikipedia.LockedPage:
# Skip this page
pass
- return
+ return
def main(args):
'''
@@ -1238,14 +1239,14 @@
generator = uploadedYesterday(site)
else:
generator = genFactory.handleArg(arg)
- if not generator:
+ if not generator:
wikipedia.output('You have to specify the generator you want to use for the
program!')
- else:
+ else:
pregenerator = pagegenerators.PreloadingGenerator(generator)
for page in pregenerator:
if page.exists() and (page.namespace() == 6) and (not page.isRedirectPage())
:
if isUncat(page):
- addUncat(page)
+ addUncat(page)
if __name__ == "__main__":
try:
Property changes on: trunk/pywikipedia/imageuncat.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/inline_images.py
===================================================================
--- trunk/pywikipedia/inline_images.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/inline_images.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -38,7 +38,7 @@
'ar': u'هذه الصورة كانت موصولة داخليا من %s. لا معلومات عن المؤلف، حالة حقوق
النشر، أو الترخيص متوفرة.',
'he': u'תמונה זו הייתה מקושרת מהדף %s. אין מידע זמין על המחבר, מצב זכויות
היוצרים או הרישיון.',
'pl': u'Obraz ten został dolinkowany z adresu %s. Brak jest informacji o
autorze, prawach autorskich czy licencji.',
- 'pt': u'Esta imagem foi inserida como linha de %s. Nenhum infomação sobre
autor, direitos autorais ou licença foi listada.',
+ 'pt': u'Esta imagem foi inserida como linha de %s. Nenhum infomação sobre
autor, direitos autorais ou licença foi listada.',
}
###################################
@@ -64,7 +64,7 @@
# TODO: check duplicates
#filename = bot.uploadImage()
#if filename:
- # text = text.replace(url, u'[[Image:%s]]' % filename) #
+ # text = text.replace(url, u'[[Image:%s]]' % filename) #
# only save if there were changes
#if text != originalText:
# page.put(text)
Modified: trunk/pywikipedia/interwiki.py
===================================================================
--- trunk/pywikipedia/interwiki.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/interwiki.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -218,7 +218,7 @@
interwiki_graph: output a graph PNG file on conflicts? You need pydot for
this:
http://dkbza.org/pydot.html
-interwiki_graph_format: the file format for interwiki graphs
+interwiki_graph_format: the file format for interwiki graphs
without_interwiki: save file with local articles without interwikis
@@ -551,7 +551,7 @@
"""Return a list of sites for all things we still need to
do"""
distinctSites = {}
- for page in self.todo:
+ for page in self.todo:
site = page.site()
distinctSites[site] = site
return distinctSites.values()
@@ -714,7 +714,7 @@
t = globalvar.showtextlink
if t:
wikipedia.output(self.originPage.get()[:t])
- # loop
+ # loop
while True:
newhint = wikipedia.input(u'Give a hint (? to see
pagetext):')
if newhint == '?':
@@ -949,9 +949,9 @@
wikipedia.output(u"Found link to %s in:" %
page2.aslink(True))
self.whereReport(page2, indent = 4)
while True:
- if acceptall:
+ if acceptall:
answer = 'a'
- else:
+ else:
answer = wikipedia.inputChoice(u'What should be
done?', ['accept', 'reject', 'give up', 'accept all'],
['a', 'r', 'g', 'l'], 'a')
if answer == 'l': # accept all
acceptall = True
@@ -1058,7 +1058,7 @@
except GiveUpOnPage:
break
- # disabled graph drawing for minor problems: it just takes too long
+ # disabled graph drawing for minor problems: it just takes too long
#if notUpdatedSites != [] and config.interwiki_graph:
# # at least one site was not updated, save a conflict graph
# self.createGraph()
@@ -1207,7 +1207,7 @@
raise SaveError
except wikipedia.EditConflict:
wikipedia.output(u'ERROR putting page: An edit conflict
occurred. Giving up.')
- raise SaveError
+ raise SaveError
except (wikipedia.SpamfilterError), error:
wikipedia.output(u'ERROR putting page: %s blacklisted by
spamfilter. Giving up.' % (error.url,))
raise SaveError
@@ -1291,7 +1291,7 @@
# We count how many pages still need to be loaded per site.
# This allows us to find out from which site to retrieve pages next
# in a way that saves bandwidth.
- # sites are keys, integers are values.
+ # sites are keys, integers are values.
# Modify this only via plus() and minus()!
self.counts = {}
self.pageGenerator = None
@@ -1413,7 +1413,7 @@
return wikipedia.getSite()
except KeyError:
pass
- # If getting the home language doesn't make sense, see how many
+ # If getting the home language doesn't make sense, see how many
# foreign page queries we can find.
return self.maxOpenSite()
@@ -1516,7 +1516,7 @@
if adding:
mods += " %s: %s" % (wikipedia.translate(insite.lang, msg)[1], ",
".join([fmt(x) for x in adding]))
- if removing:
+ if removing:
mods += " %s: %s" % (wikipedia.translate(insite.lang, msg)[2], ",
".join([fmt(x) for x in removing]))
if modifying:
mods += " %s: %s" % (wikipedia.translate(insite.lang, msg)[3], ",
".join([fmt(x) for x in modifying]))
Modified: trunk/pywikipedia/interwiki_graph.py
===================================================================
--- trunk/pywikipedia/interwiki_graph.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/interwiki_graph.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -19,12 +19,12 @@
"""
Rendering a graph can take extremely long. We use
multithreading because of that.
-
+
TODO: Find out if several threads running in parallel
can slow down the system too much. Consider adding a
mechanism to kill a thread if it takes too long.
"""
-
+
def __init__(self, graph, originPage):
threading.Thread.__init__(self)
self.graph = graph
@@ -187,10 +187,10 @@
body = CRLF.join(L)
content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
return content_type, body
-
+
def get_content_type(self, filename):
return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
-
+
def upload(self, filename):
token = self.getToken()
@@ -218,4 +218,3 @@
if __name__ == "__main__":
uploader = SpeedyShareUploader()
uploader.upload('/home/daniel/projekte/pywikipedia/interwiki-graphs/wikipedia-de-CEE.svg')
-
\ No newline at end of file
Modified: trunk/pywikipedia/isbn.py
===================================================================
--- trunk/pywikipedia/isbn.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/isbn.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1432,8 +1432,8 @@
else:
# Save the page in the background. No need to catch exceptions.
page.put_async(text)
-
+
def run(self):
comment = wikipedia.translate(wikipedia.getSite(), msg)
wikipedia.setAction(comment)
Modified: trunk/pywikipedia/login.py
===================================================================
--- trunk/pywikipedia/login.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/login.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -108,7 +108,7 @@
"""
if config.use_api_login:
predata = {
- 'action': 'login',
+ 'action': 'login',
'lgname': self.username.encode(self.site.encoding()),
'lgpassword': self.password,
'lgdomain': self.site.family.ldapDomain,
@@ -155,7 +155,7 @@
got_token = True
if 'User=' in Ldata or 'UserName=' in Ldata:
got_user = True
-
+
if got_token and got_user:
return "\n".join(L)
elif not captchaAnswer:
@@ -269,7 +269,7 @@
for familyName in namedict.iterkeys():
for lang in namedict[familyName].iterkeys():
try:
- site = wikipedia.getSite(code=lang, fam=familyName)
+ site = wikipedia.getSite(code=lang, fam=familyName)
if not forceLogin and site.loggedInAs(sysop = sysop) != None:
wikipedia.output(u'Already logged in on %s' % site)
else:
@@ -277,7 +277,7 @@
loginMan.login()
except wikipedia.NoSuchSite:
wikipedia.output(lang+ u'.' + familyName + u' is not a
valid site, please remove it from your config')
-
+
else:
loginMan = LoginManager(password, sysop = sysop)
loginMan.login()
Modified: trunk/pywikipedia/lonelypages.py
===================================================================
--- trunk/pywikipedia/lonelypages.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/lonelypages.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -3,7 +3,7 @@
"""
This is a script written to add the template "orphan" to the pages that
aren't linked by other pages.
It can give some strange Errors sometime, I hope that all of them are fixed in this
version.
-
+
These command line parameters can be used to specify which pages to work on:
¶ms;
@@ -35,7 +35,7 @@
you can find us here:
http://botwiki.sno.cc
--- Examples ---
-python lonelypages.py -enable:User:Bot/CheckBot -always
+python lonelypages.py -enable:User:Bot/CheckBot -always
"""
#
# (C) Pietrodn, it.wiki 2006-2007
@@ -45,7 +45,7 @@
#
__version__ = '$Id: lonelypages.py,v 1.0 2007/12/28 19.16.00 filnik Exp$'
#
-
+
import wikipedia, pagegenerators
import re
@@ -97,7 +97,7 @@
}
# ************* Modify only above! ************* #
-
+
def main():
# Load the configurations in the function namespace
global commento; global Template; global disambigPage; global commenttodisambig
@@ -121,7 +121,7 @@
if len(arg) == 9:
disambigPage = wikipedia.input(u'In which page should the bot save
the disambig pages?')
else:
- disambigPage = arg[10:]
+ disambigPage = arg[10:]
elif arg.startswith('-limit'):
if len(arg) == 6:
limit = int(wikipedia.input(u'How many pages do you want to
check?'))
@@ -140,7 +140,7 @@
else:
generator = [wikipedia.Page(wikipedia.getSite(), arg[6:])]
elif arg == '-always':
- always = True
+ always = True
else:
generator = genFactory.handleArg(arg)
# Retrive the site
Property changes on: trunk/pywikipedia/lonelypages.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/maintainer.py
===================================================================
--- trunk/pywikipedia/maintainer.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/maintainer.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -5,6 +5,7 @@
Note: the script requires the Python IRC library
http://python-irclib.sourceforge.net/
"""
+__version__ = '$Id$'
# Author: Balasyum
#
http://hu.wikipedia.org/wiki/User:Balasyum
Property changes on: trunk/pywikipedia/maintainer.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/pywikipedia/makecat.py
===================================================================
--- trunk/pywikipedia/makecat.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/makecat.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -45,7 +45,7 @@
'ar':u'إنشاء أو تحديث التصنيف:',
'en':u'Creation or update of category:',
'es':u'Creación o actualiza de la categoría:',
- 'fr':u'Création ou mise à jour de categorie:',
+ 'fr':u'Création ou mise à jour de categorie:',
'he':u'יצירה או עדכון של קטגוריה:',
'ia':u'Creation o actualisation de categoria:',
'it':u'La creazione o laggiornamento di categoria:',
@@ -64,7 +64,7 @@
def isdate(s):
"""returns true iff s is a date or year
"""
- dict,val = date.getAutoFormat( wikipedia.getSite().language(), s )
+ dict,val = date.getAutoFormat( wikipedia.getSite().language(), s )
return dict is not None
def needcheck(pl):
@@ -254,7 +254,7 @@
list = cat.articlesList()
for page in list:
exclude(page.title(),real_exclude=False)
- checked[page] = page
+ checked[page] = page
list = workingcat.articlesList()
if list:
for pl in list:
Modified: trunk/pywikipedia/misspelling.py
===================================================================
--- trunk/pywikipedia/misspelling.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/misspelling.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -125,8 +125,8 @@
firstPageTitle = arg[7:]
elif arg == '-main':
main_only = True
-
+
bot = MisspellingRobot(always, firstPageTitle, main_only)
bot.run()
Modified: trunk/pywikipedia/mysql_autoconnection.py
===================================================================
--- trunk/pywikipedia/mysql_autoconnection.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/mysql_autoconnection.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,8 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
-A small MySQL wrapper that catches dead MySQL connections, and tries to
-reconnect them.
+A small MySQL wrapper that catches dead MySQL connections, and tries to
+reconnect them.
"""
#
# (C) Bryan Tong Minh, 2007
@@ -28,27 +28,27 @@
2013, # Server lost
2014, # Commands out of sync
)
-
+
def __init__(self, retry_timeout = 60, max_retries = -1,
callback = lambda *args: None, *conn_args, **conn_kwargs):
-
+
self.retry_timeout = retry_timeout
self.max_retries = max_retries
self.current_retry = 0
self.callback = callback
-
+
self.conn_args = conn_args
self.conn_kwargs = conn_kwargs
-
+
self.connected = False
self.connect()
-
+
def wait(self):
if self.current_retry > self.max_retries and self.max_retries != -1:
raise RuntimeError('Maximum retries exceeded')
if self.current_retry:
self.callback(self)
- time.sleep(self.current_retry * self.retry_timeout)
+ time.sleep(self.current_retry * self.retry_timeout)
self.current_retry += 1
def __call(self, (object, function_name), *args, **kwargs):
try:
@@ -60,11 +60,11 @@
return getattr(self, function_name)(*args, **kwargs)
else:
raise
-
+
# Mimic database object
def connect(self):
self.close()
-
+
while not self.connected:
self.wait()
try:
@@ -72,13 +72,13 @@
except MySQLdb.Error, e:
self.error = e
return True
-
+
def _connect(self):
self.database = MySQLdb.connect(*self.conn_args, **self.conn_kwargs)
self.connected = True
self.current_retry = 0
self.__cursor = self.database.cursor()
-
+
def close(self):
self.current_retry = 0
self.connected = False
@@ -91,7 +91,7 @@
if type(cursorclass) is not type(self.__cursor):
self.__cursor = self.database.cursor(cursorclass)
return self
-
+
# Mimic cursor object
def __iter__(self):
return self.__cursor.__iter__()
@@ -104,34 +104,34 @@
if hasattr(attr, '__call__'):
return CallWrapper(self.__call, (obj, name))
return attr
-
-
+
+
class CallWrapper(object):
def __init__(self, executor, function):
self.__executor = executor
self.__function = function
def __call__(self, *args, **kwargs):
- return self.__executor(self.__function,
+ return self.__executor(self.__function,
*args, **kwargs)
def __getattr__(self, name):
getattr(self.__function, name)
-
-def connect(retry_timeout = 60, max_retries = -1,
+
+def connect(retry_timeout = 60, max_retries = -1,
callback = lambda *args: None, *conn_args, **conn_kwargs):
-
- return Connection(retry_timeout = retry_timeout,
- max_retries = max_retries,
- callback = callback,
+
+ return Connection(retry_timeout = retry_timeout,
+ max_retries = max_retries,
+ callback = callback,
*conn_args, **conn_kwargs)
-
+
if __name__ == '__main__':
def callback(conn):
print 'Waiting for', conn
-
+
host = raw_input('Host: ')
username = raw_input('Username: ')
password = raw_input('Password: ')
-
+
conn = connect(retry_timeout = 5, max_retries = 4, callback = callback,
host = host, user = username, passwd = password, charset = 'utf8')
cur = conn.cursor()
@@ -146,7 +146,7 @@
print 'Query ok!, please kill while connected...'
raw_input()
conn.execute('SELECT SLEEP(30), 1')
-
+
print 'Now testing inserts...'
conn.execute('USE test')
conn.execute('CREATE TEMPORARY TABLE mysql_autoconnection (value INT)')
@@ -157,7 +157,6 @@
print conn.fetchall()
print 'Query ok!'
raw_input()
-
-
-
-
\ No newline at end of file
+
+
+
Modified: trunk/pywikipedia/noreferences.py
===================================================================
--- trunk/pywikipedia/noreferences.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/noreferences.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -31,7 +31,7 @@
a list of affected articles
"""
-__version__='$Id: selflink.py 4187 2007-09-03 11:37:19Z wikipedian $'
+__version__='$Id$'
import wikipedia, pagegenerators, catlib
import editarticle
@@ -178,7 +178,7 @@
u'出典',
u'注釈',
],
- 'ko':[ #
+ 'ko':[ #
u'주석',
u'각주'
u'주석 및 참고 자료'
@@ -476,4 +476,4 @@
main()
finally:
wikipedia.stopme()
-
+
Property changes on: trunk/pywikipedia/noreferences.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/nowcommons.py
===================================================================
--- trunk/pywikipedia/nowcommons.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/nowcommons.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -125,7 +125,7 @@
],
'it': [
u'NowCommons',
- ],
+ ],
'nl': [
u'NuCommons',
u'Nucommons',
@@ -192,7 +192,7 @@
found_something = False
change_page = True
for x in regex.finditer(HTML_text):
- found_something = True
+ found_something = True
image_local = x.group('imagelocal')
image_commons = x.group('imagecommons')
if image_local in images_processed:
@@ -216,7 +216,7 @@
choice = wikipedia.inputChoice(u'The local and the commons images
have the same name, continue?', ['Yes', 'No'], ['y',
'N'], 'N')
else:
choice = wikipedia.inputChoice(u'Are the two images equal?',
['Yes', 'No'], ['y', 'N'], 'N')
- if choice.lower() in ['y', 'yes']:
+ if choice.lower() in ['y', 'yes']:
yield [image_local, image_commons]
else:
continue
@@ -297,13 +297,13 @@
oImageRobot =
image.ImageRobot(pagegenerators.FileLinksGenerator(localImagePage),
welcome.urlname(localImagePage.titleWithoutNamespace(), self.site),
commonsImagePage.titleWithoutNamespace(),
'', replacealways,
replaceloose)
- oImageRobot.run()
+ oImageRobot.run()
# refresh because we want the updated list
usingPages = len(list(wikipedia.ImagePage(self.site,
page.title()).usingPages()))
if usingPages > 0 and use_hash:
# just an enter
wikipedia.input(u'There are still %s pages with
this image, confirm the manual removal from them please.' % usingPages)
-
+
else:
wikipedia.output(u'Please change them manually.')
continue
Modified: trunk/pywikipedia/pagegenerators.py
===================================================================
--- trunk/pywikipedia/pagegenerators.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/pagegenerators.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -75,7 +75,7 @@
on the x newest pages.
-imagelinks Work on all images that are linked from a certain page.
- Argument can also be given as "-imagelinks:linkingpagetitle".
+ Argument can also be given as
"-imagelinks:linkingpagetitle".
-newimages Work on the 100 newest images. If given as -newimages:x,
will work on the x newest images.
@@ -91,7 +91,7 @@
"-start:Template:!" will make the bot work on all pages
in the template namespace.
--prefixindex Work on pages commencing with a common prefix.
+-prefixindex Work on pages commencing with a common prefix.
-regex Obsolete, use -titleregex
@@ -939,7 +939,7 @@
gen = NewpagesPageGenerator(number = int(arg[5:]))
else:
gen = NewpagesPageGenerator(number = 60)
- elif arg.startswith('-imagelinks'):
+ elif arg.startswith('-imagelinks'):
imagelinkstitle = arg[len('-imagelinks:'):]
if not imagelinkstitle:
imagelinkstitle = wikipedia.input(u'Images on which page should be
processed?')
Modified: trunk/pywikipedia/pageimport.py
===================================================================
--- trunk/pywikipedia/pageimport.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/pageimport.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -27,17 +27,17 @@
#
# Distributed under the terms of the MIT license.
#
-
-__version__ = '$Id: pageimport.py 4336 2007-09-20 14:51:04Z wikipedian $'
-
+
+__version__ = '$Id$'
+
import urllib
import wikipedia, login, config
-
+
class Importer(wikipedia.Page):
def __init__(self, site):
self.importsite = site
wikipedia.Page.__init__(self, site, 'Special:Import', None, 0)
-
+
def Import(self, target, project = 'w', crono = '1', namespace =
'', prompt = True):
"""Import the page from the wiki. Requires administrator status.
If prompt is True, asks the user if he wants to delete the page.
@@ -61,7 +61,7 @@
crono = '0'
# Fixing namespace's value.
if namespace == '0':
- namespace == ''
+ namespace == ''
answer = 'y'
if prompt:
answer = wikipedia.inputChoice(u'Do you want to import %s?' % target,
['Yes', 'No'], ['y', 'N'], 'N')
@@ -101,7 +101,7 @@
else:
wikipedia.output(u'Import failed!')
return False
-
+
if __name__=='__main__':
wikipedia.output(u'This is just a module! Read the documentation and write your
own script!')
wikipedia.stopme()
Property changes on: trunk/pywikipedia/pageimport.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/piper.py
===================================================================
--- trunk/pywikipedia/piper.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/piper.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -34,7 +34,7 @@
supported.
"""
-__version__ = '$Id: basic.py 4946 2008-01-29 14:58:25Z wikipedian $'
+__version__ = '$Id$'
import wikipedia
import pagegenerators
@@ -112,7 +112,7 @@
# file.write(text.encode("utf-8"))
# file.close()
# print "Wrote to %s" % saveName
-
+
def treat(self, page):
"""
Loads the given page, does some changes, and saves it.
Property changes on: trunk/pywikipedia/piper.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/pywikipedia/protect.py
===================================================================
--- trunk/pywikipedia/protect.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/protect.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -2,11 +2,11 @@
"""
This script can be used to protect and unprotect pages en masse.
Of course, you will need an admin account on the relevant wiki.
-
+
Syntax: python protect.py OPTION...
-
+
Command line options:
-
+
-page: Protect specified page
-cat: Protect all pages in the given category.
-nosubcats: Don't protect pages in the subcategories.
@@ -22,31 +22,31 @@
## Without support ##
## -create:PROTECTION_LEVEL Set move protection level to PROTECTION_LEVEL ##
-
+
Values for PROTECTION_LEVEL are: sysop, autoconfirmed, none.
If an operation parameter (edit, move or create) is not specified, default
protection level is 'sysop' (or 'none' if -unprotect).
-
+
Examples:
-
+
Protect everything in the category "To protect" prompting.
python protect.py -cat:"To protect" -always
-
+
Unprotect all pages listed in text file "unprotect.txt" without prompting.
python protect.py -file:unprotect.txt -unprotect
"""
-
+
# Written by
http://it.wikisource.org/wiki/Utente:Qualc1
# Created by modifying delete.py
-__version__ = '$Id: delete.py 4946 2008-01-29 14:58:25Z wikipedian $'
-
+__version__ = '$Id$'
+
#
# Distributed under the terms of the MIT license.
#
-
+
import wikipedia, catlib
import pagegenerators
-
+
# Summary messages for protecting from a category.
msg_simple_protect = {
'en': u'Bot: Protecting a list of files.',
@@ -83,12 +83,12 @@
'pt': u'Bot: Protegendo todas as imagens do artigo %s',
'zh': u'機器人: 保護頁面 %s 中的所有圖條',
}
-
+
class ProtectionRobot:
"""
This robot allows protection of pages en masse.
"""
-
+
def __init__(self, generator, summary, always = False, unprotect=False,
edit='sysop', move='sysop', create='sysop'):
"""
@@ -104,7 +104,7 @@
self.unprotect = unprotect
self.edit = edit
self.move = move
-
+
def run(self):
"""
Starts the robot's action.
@@ -115,22 +115,22 @@
print self.edit, self.move#, self.create
page.protect(unprotect=self.unprotect, reason=self.summary,
prompt=self.always,
edit=self.edit, move=self.move)
-
+
# Asks a valid protection level for "operation".
# Returns the protection level chosen by user.
def choiceProtectionLevel(operation, default):
default = default[0]
firstChar = map(lambda level: level[0], protectionLevels)
- choiceChar = wikipedia.inputChoice('Choice a protection level to %s:' %
operation,
+ choiceChar = wikipedia.inputChoice('Choice a protection level to %s:' %
operation,
protectionLevels, firstChar, default = default)
for level in protectionLevels:
if level.startswith(choiceChar):
return level
-
+
def main():
global protectionLevels
protectionLevels = ['sysop', 'autoconfirmed', 'none']
-
+
pageName = ''
summary = ''
always = False
@@ -145,7 +145,7 @@
edit = ''
move = ''
defaultProtection = 'sysop'
-
+
# read command line parameters
for arg in wikipedia.handleArgs():
if arg == '-always':
@@ -206,9 +206,9 @@
create = arg[len('-create:'):]
if create not in protectionLevels:
create = choiceProtectionLevel('create', defaultProtection)
-
+
mysite = wikipedia.getSite()
-
+
if doSinglePage:
if not summary:
summary = wikipedia.input(u'Enter a reason for the protection:')
@@ -238,7 +238,7 @@
if not summary:
summary = wikipedia.translate(mysite, msg_protect_images) % pageName
gen = pagegenerators.ImagesPageGenerator(wikipedia.Page(mysite, pageName))
-
+
if gen:
wikipedia.setAction(summary)
# We are just protecting pages, so we have no need of using a preloading page
generator
@@ -249,7 +249,7 @@
bot.run()
else:
wikipedia.showHelp(u'protect')
-
+
if __name__ == "__main__":
try:
main()
Property changes on: trunk/pywikipedia/protect.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/query.py
===================================================================
--- trunk/pywikipedia/query.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/query.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -42,7 +42,7 @@
if not useAPI:
params['noprofile'] = ''
-
+
for k,v in params.iteritems():
if type(v) == type(u''):
params[k] = ToUtf8(v)
@@ -55,18 +55,18 @@
if encodeTitle:
data = {'titles' : params['titles']}
del params['titles']
-
+
if useAPI:
path = site.api_address() + urllib.urlencode(params.items())
else:
path = site.query_address() + urllib.urlencode(params.items())
-
+
if verbose:
if titlecount > 0:
wikipedia.output(u"Requesting %d titles from %s:%s" % (titlecount,
site.lang, path))
else:
wikipedia.output(u"Request %s:%s" % (site.lang, path))
-
+
lastError = None
retry_idle_time = 5
while retryCount >= 0:
@@ -77,7 +77,7 @@
# This will also work, but all unicode strings will need to be converted from
\u notation
# decodedObj = eval( jsontext )
return simplejson.loads( jsontext )
-
+
except ValueError, error:
retryCount -= 1
wikipedia.output(u"Error downloading data: %s" % error)
@@ -92,7 +92,7 @@
if retry_idle_time > 300:
retry_idle_time = 300
-
+
raise lastError
def GetInterwikies(site, titles, extraParams = None ):
@@ -100,7 +100,7 @@
titles may be either ane title (as a string), or a list of strings
extraParams if given must be a dict() as taken by GetData()
"""
-
+
params = {'titles':ListToParam(titles), 'what' :
'redirects|langlinks'}
params = CombineParams( params, extraParams )
return GetData(site, params )
@@ -119,12 +119,12 @@
The rest will be aquired from the Wikipedia:Disambiguation Templates page.
Only links to templates will be used from that page.
"""
-
+
disambigs = set()
disambigName = u"template:disambig"
disListName = u"Wikipedia:Disambiguation Templates"
disListId = 0
-
+
templateNames = GetLinks(site, [disListName, disambigName])
for id, page in templateNames['pages'].iteritems():
if page['title'] == disambigName:
@@ -138,7 +138,7 @@
disListId = page['refid']
else:
disListId = id
-
+
# Disambig page was found
if disListId > 0:
page = templateNames['pages'][disListId]
@@ -146,7 +146,7 @@
for l in page['links']:
if l['ns'] == 10:
disambigs.add(l['*'])
-
+
return disambigs
#
#
@@ -172,7 +172,7 @@
return dict( params )
else:
raise "Unknown param type %s" % pt
-
+
def CombineParams( params1, params2 ):
"""Merge two dictionaries. If they have the same keys, their values
will
be appended one after another separated by the '|' symbol.
@@ -182,7 +182,7 @@
if params2 is None:
return params1
params2 = CleanParams( params2 )
-
+
for k, v2 in params2.iteritems():
if k in params1:
v1 = params1[k]
@@ -213,7 +213,7 @@
list = ConvToList( list )
if len(list) == 0:
return ''
-
+
encList = ''
# items may not have one symbol - '|'
for l in list:
Modified: trunk/pywikipedia/rciw.py
===================================================================
--- trunk/pywikipedia/rciw.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/rciw.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -13,6 +13,7 @@
-safe Does not handle the same page more than once in a session
"""
+__version__ = '$Id$'
# Authors: Kisbes
#
http://hu.wikipedia.org/wiki/User:Kisbes
Property changes on: trunk/pywikipedia/rciw.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/rcsort.py
===================================================================
--- trunk/pywikipedia/rcsort.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/rcsort.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -7,6 +7,7 @@
# Currently only works on Dutch Wikipedia, I do intend to make it more generally
# usable.
# Permission has been asked to run this on the toolserver.
+__version__ = '$Id$'
import cgi
import cgitb
Modified: trunk/pywikipedia/redirect.py
===================================================================
--- trunk/pywikipedia/redirect.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/redirect.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -431,9 +431,9 @@
u'Warning: redirect target (%s) is on a different site.'
% (targetPage.aslink()))
if self.always:
- break # skip if automatic
+ break # skip if automatic
# watch out for redirect loops
- if redirList.count(u'%s:%s'
+ if redirList.count(u'%s:%s'
% (targetPage.site().lang,
targetPage.sectionFreeTitle())
) > 0:
Modified: trunk/pywikipedia/reflinks.py
===================================================================
--- trunk/pywikipedia/reflinks.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/reflinks.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
"""
-This bot will search for references which are only made of a link
-without title, (i.e. <ref>[http://www.google.fr/]</ref> or
-<ref>http://www.google.fr/</ref>) and will fetch the html title from
+This bot will search for references which are only made of a link
+without title, (i.e. <ref>[http://www.google.fr/]</ref> or
+<ref>http://www.google.fr/</ref>) and will fetch the html title from
the link to use it as the title of the wiki link in the reference, i.e.
<ref>[http://www.google.fr/search?q=test test - Google Search]</ref>
@@ -27,7 +27,7 @@
-xmlstart Page to start with when using an XML dump
--ignorepdf Do not handle PDF files (handy if you use Windows and
+-ignorepdf Do not handle PDF files (handy if you use Windows and
can't get pdfinfo)
Basic pagegenerators commands, -page, etc...
@@ -35,6 +35,8 @@
# (C) 2008 - Nicolas Dumazet ( en:User:NicDumZ )
#
# Distributed under the terms of the GPL
+"""
+__version__ = '$Id$'
from BeautifulSoup import UnicodeDammit
import sys, re, urllib2, httplib, socket, codecs, ftplib
@@ -136,7 +138,7 @@
def __iter__(self):
return self
-
+
def next(self):
while True:
try:
@@ -172,7 +174,7 @@
def refLink(self):
"""No title has been found, return the unbracketed
link"""
return '<ref%s>%s</ref>' % (self.refname, self.link)
-
+
def refDead(self):
"""Dead link, tag it with a {{dead link}}"""
tag = wikipedia.translate(self.site, deadLinkTag) % self.link
@@ -283,7 +285,7 @@
v[3] = True
foundRefNames[name] = 1
groupdict[content] = v
-
+
id = 1
while foundRefNames.has_key('autogenerated%s' % id):
id += 1
@@ -304,25 +306,25 @@
name = u'"%s"' % name
named = u'<ref %sname=%s>%s</ref>' % (group, name,
k)
text = text.replace(v[1][0], named, 1)
-
+
# make sure that the first (named ref) is not
# removed later :
pos = text.index(named) + len(named)
header = text[:pos]
end = text[pos:]
-
+
unnamed = u'<ref %sname=%s />' % (group, name)
for ref in v[1][1:]:
end = end.replace(ref, unnamed)
- text = header + end
-
+ text = header + end
+
for (k,v) in namedRepl.iteritems():
# TODO : Support ref groups
name = v[0]
if v[1]:
name = u'"%s"' % name
text = re.sub(u'<ref
name\s*=\s*(?P<quote>"?)\s*%s\s*(?P=quote)\s*/>' % k, u'<ref
name=%s />' % name, text)
- return text
+ return text
class ReferencesRobot:
def __init__(self, generator, acceptall = False, limit = None, ignorepdf = False ):
@@ -348,12 +350,12 @@
self.norefbot = noreferences.NoReferencesBot(None)
self.deduplicator = DuplicateReferences()
-
+
try :
- self.stopPageRevId = wikipedia.Page(self.site,
+ self.stopPageRevId = wikipedia.Page(self.site,
self.stopPage).latestRevision()
except wikipedia.NoPage :
- wikipedia.output(u'The stop page %s does not exist'
+ wikipedia.output(u'The stop page %s does not exist'
% self.stopPage.aslink())
raise
@@ -368,18 +370,18 @@
# Authorized mime types for HTML pages
self.MIME =
re.compile(ur'application/(?:xhtml\+xml|xml)|text/(?:ht|x)ml')
-
+
def put_page(self, page, new):
"""
Prints diffs between orginal and new (text), puts new text for page
"""
- wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default}
<<<"
+ wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default}
<<<"
% page.title())
wikipedia.showDiff(page.get(), new)
if not self.acceptall:
choice = wikipedia.inputChoice(u'Do you want to accept ' +
- u'these changes?',
- ['Yes', 'No', 'All'],
+ u'these changes?',
+ ['Yes', 'No', 'All'],
['y', 'N', 'a'],
'N')
if choice == 'a':
self.acceptall = True
@@ -389,25 +391,25 @@
try:
page.put(new)
except wikipedia.EditConflict:
- wikipedia.output(u'Skipping %s because of edit conflict'
+ wikipedia.output(u'Skipping %s because of edit conflict'
% (page.title(),))
except wikipedia.SpamfilterError, e:
wikipedia.output(u'Cannot change %s because of blacklist entry
%s' % (page.title(), e.url))
except wikipedia.PageNotSaved, error:
wikipedia.output(u'Error putting page: %s' % (error.args,))
except wikipedia.LockedPage:
- wikipedia.output(u'Skipping %s (locked page)'
+ wikipedia.output(u'Skipping %s (locked page)'
% (page.title(),))
except wikipedia.ServerError, e:
wikipedia.output(u'Server Error : %s' % e)
def httpError(self, err_num, link, pagetitleaslink):
"""Log HTTP Error"""
- wikipedia.output(u'HTTP error (%s) for %s on %s'
+ wikipedia.output(u'HTTP error (%s) for %s on %s'
% (err_num, link, pagetitleaslink),
toStdout = True)
- def getPDFTitle(self, ref, f):
+ def getPDFTitle(self, ref, f):
"""
Use pdfinfo to retrieve title from a PDF.
Unix-only, I'm afraid.
@@ -441,7 +443,7 @@
"""
wikipedia.setAction(wikipedia.translate(self.site, msg))
try:
- deadLinks = codecs.open(listof404pages, 'r',
'latin_1').read()
+ deadLinks = codecs.open(listof404pages, 'r',
'latin_1').read()
except IOError:
wikipedia.output('You need to download
http://www.twoevils.org/files/wikipedia/404-links.txt.gz and to ungzip it in the same
directory')
raise
@@ -452,7 +454,7 @@
# Load the page's text from the wiki
new_text = page.get()
if not page.canBeEdited():
- wikipedia.output(u"You can't edit page %s"
+ wikipedia.output(u"You can't edit page %s"
% page.aslink())
continue
except wikipedia.NoPage:
@@ -470,7 +472,7 @@
if u'jstor.org' in link:
#TODO: Clean URL blacklist
continue
-
+
ref = RefLink(link, match.group('name'))
f = None
try:
@@ -515,17 +517,17 @@
wikipedia.output(u'\03{lightred}Bad link\03{default} : %s in
%s' % (ref.url, page.aslink()))
continue
except urllib2.HTTPError, e:
- wikipedia.output(u'HTTP error (%s) for %s on %s'
+ wikipedia.output(u'HTTP error (%s) for %s on %s'
% (e.code, ref.url, page.aslink()),
toStdout = True)
- # 410 Gone, indicates that the resource has been purposely removed
+ # 410 Gone, indicates that the resource has been purposely removed
if e.code == 410 or (e.code == 404 and (u'\t%s\t' % ref.url
in deadLinks)):
repl = ref.refDead()
new_text = new_text.replace(match.group(), repl)
continue
- except (urllib2.URLError,
- socket.error,
- IOError,
+ except (urllib2.URLError,
+ socket.error,
+ IOError,
httplib.error), e:
#except (urllib2.URLError, socket.timeout, ftplib.error, httplib.error,
socket.error), e:
wikipedia.output(u'Can\'t retrieve page %s : %s' %
(ref.url, e))
@@ -537,7 +539,7 @@
finally:
if f:
f.close()
-
+
#remove <script>/<style>/comments/CDATA tags
linkedpagetext = self.NON_HTML.sub('', linkedpagetext)
@@ -546,10 +548,10 @@
if meta_content:
tag = meta_content.group()
# Prefer the contentType from the HTTP header :
- if not contentType:
+ if not contentType:
contentType = tag
s = self.CHARSET.search(tag)
- if s:
+ if s:
tmp = s.group('enc').strip("\"'
").lower()
naked = re.sub('[ _\-]', '', tmp)
# Convert to python correct encoding names
@@ -570,7 +572,7 @@
repl = ref.refLink()
new_text = new_text.replace(match.group(), repl)
continue
-
+
# Ugly hacks to try to survive when both server and page return no
encoding.
# Uses most used encodings for each national suffix
if u'.ru' in ref.link or u'.su' in ref.link:
@@ -584,12 +586,12 @@
enc.append("cp949")
elif u'.zh' in ref.link:
enc.append("gbk")
-
+
#print(enc)
u = UnicodeDammit(linkedpagetext, overrideEncodings = enc)
#print(u.triedEncodings)
-
-
+
+
if not u.unicode:
#Some page have utf-8 AND windows-1252 characters,
#Can't easily parse them. (~1 on 1000)
@@ -597,8 +599,8 @@
new_text = new_text.replace(match.group(), repl)
wikipedia.output('%s : Hybrid encoding...' % ref.link)
continue
-
+
# Retrieves the first non empty string inside <title> tags
for m in self.TITLE.finditer(u.unicode):
t = m.group()
@@ -607,7 +609,7 @@
ref.transform()
if ref.title:
break;
-
+
if not ref.title:
repl = ref.refLink()
new_text = new_text.replace(match.group(), repl)
@@ -617,20 +619,20 @@
# BeautifulSoup thinks that the original encoding of our page was not
one
# of the encodings we specified. Output a warning.
wikipedia.output(u'\03{lightpurple}ENCODING\03{default} : %s
(%s)' % (ref.link, ref.title))
-
+
# XXX Ugly hack
if u'é' in ref.title:
repl = ref.refLink()
new_text = new_text.replace(match.group(), repl)
wikipedia.output(u'%s : Hybrid encoding...' % ref.link)
continue
-
+
if self.titleBlackList.match(ref.title):
repl = ref.refLink()
new_text = new_text.replace(match.group(), repl)
wikipedia.output(u'\03{lightred}WARNING\03{default} %s :
Blacklisted title (%s)' % (ref.link, ref.title))
continue
-
+
# Truncate long titles. 175 is arbitrary
if len(ref.title) > 175:
ref.title = ref.title[:175] + "..."
@@ -646,7 +648,7 @@
new_text = self.deduplicator.process(new_text)
if new_text == page.get():
- wikipedia.output('No changes were necessary in %s'
+ wikipedia.output('No changes were necessary in %s'
% page.aslink())
continue
@@ -659,7 +661,7 @@
if editedpages % 20 == 0:
wikipedia.output('\03{lightgreen}Checking stop
page...\03{default}')
- actualRev = wikipedia.Page(self.site,
+ actualRev = wikipedia.Page(self.site,
self.stopPage).latestRevision()
if actualRev != self.stopPageRevId:
wikipedia.output(u'[[%s]] has been edited : Someone wants us to
stop.' % self.stopPage)
@@ -667,7 +669,7 @@
def main():
genFactory = pagegenerators.GeneratorFactory()
-
+
PageTitles = []
xmlFilename = None
always = False
@@ -705,7 +707,7 @@
xmlFilename = arg[5:]
else:
generator = genFactory.handleArg(arg)
-
+
if xmlFilename:
try:
xmlStart
Property changes on: trunk/pywikipedia/reflinks.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: trunk/pywikipedia/replace.py
===================================================================
--- trunk/pywikipedia/replace.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/replace.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -468,7 +468,7 @@
'inside-tags': [],
'require-title': [], # using a seperate requirements dict needs some
} # major refactoring of code.
-
+
# Should the elements of 'replacements' and 'exceptions' be
interpreted
# as regular expressions?
regex = False
@@ -539,7 +539,7 @@
elif arg.startswith('-fix:'):
fix = arg[5:]
elif arg.startswith('-sleep:'):
- sleep = float(arg[7:])
+ sleep = float(arg[7:])
elif arg == '-always':
acceptall = True
elif arg == '-recursive':
Modified: trunk/pywikipedia/revertbot.py
===================================================================
--- trunk/pywikipedia/revertbot.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/revertbot.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -1,7 +1,7 @@
import wikipedia
import simplejson
-__version__ = '$Id:$'
+__version__ = '$Id$'
"""
Copyright 2008 - Bryan Tong Minh
@@ -10,13 +10,13 @@
class BaseRevertBot(object):
""" Base revert bot
-
+
Subclass this bot and override callback to get it to do something useful.
"""
def __init__(self, site, comment = None):
self.site = site
self.comment = comment
-
+
def get_contributions(self, max = -1, ns = None):
address = self.site.api_address()
predata = {
@@ -28,7 +28,7 @@
}
if ns is not None: predata['ucnamespace'] = ns
if max < 500 and max != -1: predata['uclimit'] = str(max)
-
+
count = 0
iterator = iter(xrange(0))
never_continue = False
@@ -49,13 +49,13 @@
else:
count += 1
yield item
-
+
def revert_contribs(self, callback = None):
self.site.forceLogin()
-
+
if callback is None:
callback = self.callback
-
+
contribs = self.get_contributions()
for item in contribs:
try:
@@ -67,10 +67,10 @@
self.log(u'Skipped %s' % item['title'])
except StopIteration:
return
-
+
def callback(self, item):
return 'top' in item
-
+
def revert(self, item):
predata = {
'action': 'query',
@@ -83,24 +83,24 @@
}
response, data = self.site.postForm(self.site.api_address(), predata)
data = simplejson.loads(data)
-
+
if 'error' in data:
raise RuntimeError(data['error'])
-
+
pages = data['query'].get('pages', ())
if not pages: return False
page = pages.itervalues().next()
if len(page.get('revisions', ())) != 2: return False
rev = page['revisions'][1]
-
- comment = u'Reverted to revision %s by %s on %s' % (rev['revid'],
+
+ comment = u'Reverted to revision %s by %s on %s' %
(rev['revid'],
rev['user'], rev['timestamp'])
if self.comment: comment += ': ' + self.comment
-
+
page = wikipedia.Page(self.site, item['title'])
page.put(rev['*'], comment)
return comment
-
+
def log(self, msg):
wikipedia.output(msg)
-
+
Property changes on: trunk/pywikipedia/revertbot.py
___________________________________________________________________
Name: svn:keywords
- id
+ Author Date Id Revision
Modified: trunk/pywikipedia/saveHTML.py
===================================================================
--- trunk/pywikipedia/saveHTML.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/saveHTML.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -10,7 +10,7 @@
Options:
- -o: Specifies the output-directory where to save the files
+ -o: Specifies the output-directory where to save the files
-images: Downlaod all images
-overwrite:[I|A|B] Ignore existing Images|Article|Both and
@@ -91,7 +91,7 @@
"%29": ")",
"%2C": ","
}
-
+
for entry in dict:
str = re.sub(entry, dict[entry], str)
return str
@@ -130,7 +130,7 @@
save_images = False
overwrite_images = False
overwrite_articles = False
-
+
for arg in wikipedia.handleArgs():
if arg.startswith("-lang:"):
lang = arg[6:]
@@ -139,7 +139,7 @@
R=re.compile(r'.*\[\[([^\]]*)\]\].*')
m = False
for line in f.readlines():
- m=R.match(line)
+ m=R.match(line)
if m:
sa.append(string.replace(m.group(1), " ", "_"))
else:
@@ -161,7 +161,7 @@
else:
sa.append(arg.replace(" ", "_"))
- headers = {"Content-type": "application/x-www-form-urlencoded",
+ headers = {"Content-type": "application/x-www-form-urlencoded",
"User-agent": wikipedia.useragent}
print "opening connection to", mysite.hostname(),
conn = httplib.HTTPConnection(mysite.hostname())
@@ -185,14 +185,14 @@
print ua + " failed. reading",
result = R.match(response.getheader("Location", ))
ua = result.group(1)
- print ua
+ print ua
data = extractArticle(data)
f = open (output_directory + filename + ".txt", 'w')
f.write (data['article'] + '\n' + data['footer'])
f.close()
print "saved " + article
-
+
if save_images:
images = extractImages(data['article'])
for i in images:
Modified: trunk/pywikipedia/solve_disambiguation.py
===================================================================
--- trunk/pywikipedia/solve_disambiguation.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/solve_disambiguation.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -124,7 +124,7 @@
'sr': u'Решавање вишезначних одредница помоћу бота: %s - Removed
link(s)',
'sv': u'Länkar direkt till rätt artikel för: %s - Tog bort
länk(ar)',
}
-
+
# Summary message when working on redirects
msg_redir = {
'ar': u'توضيح بمساعدة روبوت: %s - غير الوصلة أو الوصلات إلى %s',
@@ -252,7 +252,7 @@
u'Wikipedia:Liste mathematischer Themen/BKS',
u'Wikipedia:Liste mathematischer Themen/Redirects',
u'Wikipedia:Löschkandidaten/.+',
- u'Wikipedia:Qualitätsoffensive/UNO', #requested by Benutzer:Addicted
+ u'Wikipedia:Qualitätsoffensive/UNO', #requested by Benutzer:Addicted
u'Wikipedia:WikiProjekt Altertumswissenschaft/.+',
u'Wikipedia:WikiProjekt Verwaiste Seiten/Begriffsklärungen',
],
@@ -442,7 +442,7 @@
# if run with the -primary argument, enable the ignore manager
self.primaryIgnoreManager = PrimaryIgnoreManager(disambPage,
enabled=primary)
-
+
def __iter__(self):
# TODO: start yielding before all referring pages have been found
refs = [page for page in self.disambPage.getReferences(follow_redirects = False,
withTemplateInclusion = False)]
@@ -472,7 +472,7 @@
def __init__(self, disambPage, enabled = False):
self.disambPage = disambPage
self.enabled = enabled
-
+
self.ignorelist = []
filename = wikipedia.config.datafilepath('disambiguations',
self.disambPage.titleForFilename() + '.txt')
@@ -492,7 +492,7 @@
def isIgnored(self, refPage):
return self.enabled and refPage.urlname() in self.ignorelist
-
+
def ignore(self, refPage):
if self.enabled:
# Skip this occurence next time.
@@ -525,7 +525,7 @@
u'{{[Pp]rocessing}}',
),
}
-
+
def __init__(self, always, alternatives, getAlternatives, generator, primary,
main_only):
self.always = always
self.alternatives = alternatives
@@ -539,7 +539,7 @@
self.comment = None
self.setupRegexes()
-
+
def checkContents(self, text):
'''
For a given text, returns False if none of the regular
@@ -553,14 +553,14 @@
if match:
return match.group()
return None
-
+
def makeAlternativesUnique(self):
# remove duplicate entries
result={}
for i in self.alternatives:
result[i]=None
self.alternatives = result.keys()
-
+
def listAlternatives(self):
list = u'\n'
for i in range(len(self.alternatives)):
@@ -583,7 +583,7 @@
# group linktrail is the link trail, that's letters after ]] which are part
of the word.
# note that the definition of 'letter' varies from language to language.
self.linkR =
re.compile(r'\[\[(?P<title>[^\]\|#]*)(?P<section>#[^\]\|]*)?(\|(?P<label>[^\]]*))?\]\](?P<linktrail>'
+ linktrail + ')')
-
+
def treat(self, refPage, disambPage):
"""
Parameters:
@@ -660,7 +660,7 @@
continue
if linkPage != disambPage:
continue
-
+
n += 1
# how many bytes should be displayed around the current link
context = 60
@@ -709,7 +709,7 @@
context *= 2
else:
break
-
+
if choice in ['e', 'E']:
# user has edited the page and then pressed 'OK'
edited = True
@@ -731,12 +731,12 @@
elif choice in ['x', 'X'] and edited:
# Save the page as is
break
-
+
# The link looks like this:
# [[page_title|link_text]]trailing_chars
page_title = m.group('title')
link_text = m.group('label')
-
+
if not link_text:
# or like this: [[page_title]]trailing_chars
link_text = page_title
@@ -747,7 +747,7 @@
trailing_chars = m.group('linktrail')
if trailing_chars:
link_text += trailing_chars
-
+
if choice in ['u', 'U']:
# unlink - we remove the section if there's any
text = text[:m.start()] + link_text + text[m.end():]
@@ -762,7 +762,7 @@
replaceit = True
else:
replaceit = False
-
+
try:
choice=int(choice)
except ValueError:
@@ -814,7 +814,7 @@
except wikipedia.PageNotSaved, error:
wikipedia.output(u'Page not saved: %s' % error.args)
return True
-
+
def findAlternatives(self, disambPage):
if disambPage.isRedirectPage() and not self.primary:
try:
@@ -859,7 +859,7 @@
return False
self.alternatives += links
return True
-
+
def setSummaryMessage(self, disambPage, new_targets = [], unlink = False):
# make list of new targets
targets = ''
@@ -867,10 +867,10 @@
targets += u'[[%s]], ' % page_title
# remove last comma
targets = targets[:-2]
-
+
if not targets:
targets = wikipedia.translate(self.mysite, unknown_msg)
-
+
# first check whether user has customized the edit comment
if wikipedia.config.disambiguation_comment.has_key(self.mysite.family.name) and
wikipedia.config.disambiguation_comment[self.mysite.family.name].has_key(self.mylang):
try:
@@ -895,7 +895,7 @@
self.comment = wikipedia.translate(self.mysite, msg_unlink) %
disambPage.title()
else:
self.comment = wikipedia.translate(self.mysite, msg) %
(disambPage.title(), targets)
-
+
def run(self):
if self.main_only:
if not ignore_title.has_key(self.mysite.family.name):
@@ -918,7 +918,7 @@
else:
self.alternatives.sort()
self.listAlternatives()
-
+
gen = ReferringPageGeneratorWithIgnore(disambPage, self.primary)
preloadingGen = pagegenerators.PreloadingGenerator(gen)
for refPage in preloadingGen:
@@ -926,7 +926,7 @@
# run until the user selected 'quit'
if not self.treat(refPage, disambPage):
break
-
+
# clear alternatives before working on next disambiguation page
self.alternatives = []
@@ -995,7 +995,7 @@
wikipedia.showHelp()
else:
pageTitle.append(arg)
-
+
# if the disambiguation page is given as a command line argument,
# connect the title's parts with spaces
if pageTitle != []:
Modified: trunk/pywikipedia/spellcheck.py
===================================================================
--- trunk/pywikipedia/spellcheck.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/spellcheck.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -96,7 +96,7 @@
change = previous[j-1]
if a[j-1] != b[i-1]:
change = change + 1
- current[j] = min(add, delete, change)
+ current[j] = min(add, delete, change)
return current[n]
def getalternatives(string):
@@ -343,7 +343,7 @@
if self.word.find(self.derive()) == -1:
return wikipedia.input(u"Please give the result of replacing %s by %s in
%s:"%(self.derive(),rep,self.word))
return self.word.replace(self.derive(),rep)
-
+
def isCorrect(self,checkalternative = False):
# If checkalternative is True, the word will only be found incorrect if
# it is on the spelling list as a spelling error. Otherwise it will
@@ -506,7 +506,7 @@
text = spellcheck(text, checknames = checknames,knownonly=knownonly)
if text != page.get():
page.put(text)
-
+
else:
title = ' '.join(title)
while title != '':
Modified: trunk/pywikipedia/standardize_interwiki.py
===================================================================
--- trunk/pywikipedia/standardize_interwiki.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/standardize_interwiki.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -2,9 +2,9 @@
# -*- coding: utf-8 -*-
"""
Loop over all pages in the home wiki, standardizing the interwiki links.
-
+
Parameters:
-
+
-start: - Set from what page you want to start
"""
#
@@ -15,11 +15,11 @@
#
__version__='$Id$'
#
-
+
import os, sys
import wikipedia, config
import difflib
-
+
# The summary that the Bot will use.
comment = {
'ar':u'روبوت: توحيد قياسي للإنترويكي',
@@ -43,7 +43,7 @@
debug = 0
start = '!'
nothing = False
-
+
# Load the default parameters and start
for arg in wikipedia.handleArgs():
if arg.startswith('-start'):
Modified: trunk/pywikipedia/standardize_notes.py
===================================================================
--- trunk/pywikipedia/standardize_notes.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/standardize_notes.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -29,7 +29,7 @@
If the -regex argument is given, the first argument will be
regarded as a regular expression, and the second argument might
contain expressions like \\1 or \g<name>.
-
+
NOTE: Only use either -sql or -file or -page, but don't mix them.
"""
# Derived from replace.py
@@ -76,7 +76,7 @@
}
fixes = {
- # These replacements will convert alternate reference formats to format used by this
tool.
+ # These replacements will convert alternate reference formats to format used by this
tool.
'ALTREFS': {
'regex': True,
# We don't want to mess up pages which discuss HTML tags, so we skip
@@ -118,7 +118,7 @@
}
# names of reference section names
-referencesectionnames = [
+referencesectionnames = [
'bibliography',
'citation',
'citations',
@@ -212,13 +212,13 @@
self.sqlfilename = sqlfilename
self.categoryname = categoryname
self.pagenames = pagenames
-
+
def read_pages_from_sql_dump(self):
"""
Generator which will yield Pages to pages that might contain text to
replace. These pages will be retrieved from a local sql dump file
(cur table).
-
+
Arguments:
* sqlfilename - the dump's path, either absolute or relative
* replacements - a dictionary where old texts are keys and new texts
@@ -257,13 +257,13 @@
if entry.text.find(old) != -1:
yield wikipedia.Page(mysite, entry.full_title())
break
-
+
def read_pages_from_category(self):
"""
Generator which will yield pages that are listed in a text file created by
the bot operator. Will regard everything inside [[double brackets]] as a
page name, and yield Pages for these pages.
-
+
Arguments:
* textfilename - the textfile's path, either absolute or relative
"""
@@ -277,7 +277,7 @@
Generator which will yield pages that are listed in a text file created by
the bot operator. Will regard everything inside [[double brackets]] as a
page name, and yield Pages for these pages.
-
+
Arguments:
* textfilename - the textfile's path, either absolute or relative
"""
@@ -292,20 +292,20 @@
if m:
yield wikipedia.Page(wikipedia.getSite(), m.group(1))
f.close()
-
+
def read_pages_from_wiki_page(self):
'''
Generator which will yield pages that are listed in a wiki page. Will
regard everything inside [[double brackets]] as a page name, except for
interwiki and category links, and yield Pages for these pages.
-
+
Arguments:
* pagetitle - the title of a page on the home wiki
'''
listpage = wikipedia.Page(wikipedia.getSite(), self.pagetitle)
list = wikipedia.get(listpage)
# TODO - UNFINISHED
-
+
# TODO: Make MediaWiki's search feature available.
def __iter__(self):
'''
@@ -337,7 +337,7 @@
def checkExceptions(self, original_text):
"""
- If one of the exceptions applies for the given text, returns the
+ If one of the exceptions applies for the given text, returns the
substring. which matches the exception. Otherwise it returns None.
"""
for exception in self.exceptions:
@@ -392,7 +392,7 @@
wikipedia.output( u"Rebuilding References section" )
new_text = self.doUpdateReferencesSection( new_text, self.refusage,
refsectionname )
return new_text
-
+
def doConvertExternalLinks(self, original_text):
"""
Returns the text which is generated by converting external links to References.
@@ -581,7 +581,7 @@
if not rp.can_fetch( "*", extlink_linkname ):
wikipedia.output( u'Robot prohibited: %s' %
unicode(extlink_linkname) )
else: # else access allowed
- try:
+ try:
if have_httpcache:
cache = HTTPCache( extlink_linkname )
urlfile = cache.filename() # filename of cached date
@@ -631,7 +631,7 @@
maxalines -= 1 # reduce number of lines left to consider
titleRE =
re.search("(?i)<title>(?P<HTMLtitle>[^<>]+)", aline)
if titleRE:
- try:
+ try:
urltitle =
unicode(titleRE.group('HTMLtitle'), 'utf-8')
except:
urltitle = u' ' # error, no title
@@ -654,14 +654,14 @@
if titleRE:
if titleRE.group('HTMLtitle'):
urltitle = u''
- try:
+ try:
urltitle =
unicode(titleRE.group('HTMLtitle'), 'utf-8')
urltitle = u'
'.join(urltitle.split()) # merge whitespace
wikipedia.output( u'::::Title:
%s' % urltitle )
except:
aline = urlobj.read()
continue
- else:
+ else:
aline = urlobj.read()
continue
break # found a title so stop looking
@@ -995,7 +995,7 @@
self.acceptall = True
if self.acceptall or choice in ['y', 'Y']:
pl.put(new_text)
-
+
def main():
# How we want to retrieve information on which pages need to be changed.
# Can either be 'sqldump', 'textfile' or 'userinput'.
Modified: trunk/pywikipedia/table2wiki.py
===================================================================
--- trunk/pywikipedia/table2wiki.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/table2wiki.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -126,7 +126,7 @@
for entry in self.xmldump.parse():
if tableTagR.search(entry.text):
yield wikipedia.Page(wikipedia.getSite(), entry.title)
-
+
class Table2WikiRobot:
def __init__(self, generator, debug = False, quietMode = False):
self.generator = generator
@@ -155,11 +155,11 @@
while num != 0:
newTable, num = re.subn("([^\r\n]{1})(<[tT]{1}[dDhHrR]{1})",
r"\1\r\n\2", newTable)
-
+
##################
# every open-tag gets a new line.
-
-
+
+
##################
# Note that we added the ## characters in markActiveTables().
# <table> tag with attributes, with more text on the same line
@@ -177,7 +177,7 @@
# end </table>
newTable = re.sub("(?i)[\s]*<\/##table##>",
"\r\n|}", newTable)
-
+
##################
# caption with attributes
newTable = re.sub("(?i)<caption
(?P<attr>[\w\W]*?)>(?P<caption>[\w\W]*?)<\/caption>",
@@ -185,7 +185,7 @@
# caption without attributes
newTable =
re.sub("(?i)<caption>(?P<caption>[\w\W]*?)<\/caption>",
r"\r\n|+ \g<caption>", newTable)
-
+
##################
# <th> often people don't write them within <tr>, be warned!
# <th> with attributes
@@ -204,7 +204,7 @@
if n>0:
warning_messages.append(u'WARNING: found <th> without </th>.
(%d occurences)\n' % n)
warnings += n
-
+
# <th> with attributes, without closing </th>
newTable, n = re.subn("(?i)[\r\n]+<th(?P<attr>
[^>]*?)>(?P<header>[\w\W]*?)[\r\n]+",
r"\n!\g<attr> | \g<header>\r\n",
newTable)
@@ -212,26 +212,26 @@
warning_messages.append(u'WARNING: found <th ...> without
</th>. (%d occurences\n)' % n)
warnings += n
-
+
##################
# <tr> with attributes
newTable = re.sub("(?i)[\r\n]*<tr(?P<attr>
[^>]*?)>[\r\n]*",
r"\r\n|-----\g<attr>\r\n", newTable)
-
+
# <tr> without attributes
newTable = re.sub("(?i)[\r\n]*<tr>[\r\n]*",
r"\r\n|-----\r\n", newTable)
-
+
##################
# normal <td> without arguments
newTable =
re.sub("(?i)[\r\n]+<td>(?P<cell>[\w\W]*?)<\/td>",
r"\r\n| \g<cell>\r\n", newTable)
-
+
##################
# normal <td> with arguments
newTable = re.sub("(?i)[\r\n]+<td(?P<attr>
[^>]*?)>(?P<cell>[\w\W]*?)<\/td>",
r"\r\n|\g<attr> | \g<cell>", newTable)
-
+
# WARNING: this sub might eat cells of bad HTML, but most likely it
# will correct errors
# TODO: some more docu please
@@ -240,7 +240,7 @@
if n>0:
warning_messages.append(u'<td> used where </td> was expected.
(%d occurences)\n' % n)
warnings += n
-
+
# fail save, sometimes it's a <td><td></tr>
# newTable, n =
re.subn("[\r\n]+<(td|TD)>([^<]*?)<(td|TD)><\/(tr|TR)>",
# "\r\n| \\2\r\n", newTable)
@@ -255,27 +255,27 @@
r"\r\n|\2 | \3\r\n", newTable)
if n>0:
warning_messages.append(u'WARNING: (sorry, bot code unreadable (1). I
don\'t know why this warning is given.) (%d occurences)\n' % n)
-
+
# fail save. sometimes people forget </td>
- # <td> without arguments, with missing </td>
+ # <td> without arguments, with missing </td>
newTable, n =
re.subn("(?i)<td>(?P<cell>[^<]*?)[\r\n]+",
r"\r\n| \g<cell>\r\n", newTable)
if n>0:
warning_messages.append(u'NOTE: Found <td> without </td>.
This shouldn\'t cause problems.\n')
-
- # <td> with attributes, with missing </td>
+
+ # <td> with attributes, with missing </td>
newTable, n = re.subn("(?i)[\r\n]*<td(?P<attr>
[^>]*?)>(?P<cell>[\w\W]*?)[\r\n]+",
r"\r\n|\g<attr> | \g<cell>\r\n",
newTable)
if n > 0:
warning_messages.append(u'NOTE: Found <td> without </td>.
This shouldn\'t cause problems.\n')
-
-
+
+
##################
# Garbage collecting ;-)
newTable = re.sub("(?i)<td>[\r\n]*<\/tr>", "",
newTable)
# delete closing tags
newTable = re.sub("(?i)[\r\n]*<\/t[rdh]>", "",
newTable)
-
+
##################
# OK, that's only theory but works most times.
# Most browsers assume that <th> gets a new row and we do the same
@@ -286,14 +286,14 @@
# newTable, n = re.subn("([\r\n]+\!\ [^\r\n]*?[\r\n]+)(\|\ )",
# "\\1|-----\r\n\\2", newTable)
# warnings = warnings + n
-
-
+
+
##################
# most <th> come with '''title'''. Senseless in my
eyes cuz
# <th> should be bold anyways.
newTable =
re.sub("[\r\n]+\!([^'\n\r]*)'''([^'\r\n]*)'''",
r"\r\n!\1\2", newTable)
-
+
##################
# kills indention within tables. Be warned, it might seldom bring
# bad results.
@@ -303,7 +303,7 @@
while num != 0:
newTable, num = re.subn("(\{\|[\w\W]*?)\n[
\t]+([\w\W]*?\|\})",
r"\1\r\n\2", newTable)
-
+
##################
# kills additional spaces after | or ! or {|
# This line was creating problems, so I commented it out --Daniel
@@ -314,9 +314,9 @@
# kill extra new-lines
newTable = re.sub("[\r\n]{4,}(\!|\|)",
r"\r\n\1", newTable);
-
-
- ##################
+
+
+ ##################
# shortening if <table> had no arguments/parameters
newTable = re.sub("[\r\n]+\{\|[\ ]+\| ", "\r\n\{| ",
newTable)
# shortening if <td> had no articles
@@ -325,7 +325,7 @@
newTable = re.sub("\n\|\+[\ ]+\|", "\n|+ ", newTable)
# shortening of <caption> had no articles
newTable = re.sub("[\r\n]+\![\ ]+\| ", "\r\n! ", newTable)
-
+
##################
# proper attributes. attribute values need to be in quotation marks.
num = 1
@@ -349,7 +349,7 @@
# group 3 are the remaining attribute key - value pairs.
newTable, num = re.subn(r'([\r\n]+(?:!|\|)[^\r\n\|]+) *=
*([^"\s>]+)([^\|\r\n]*)\|',
r'\1="\2"\3|', newTable, 1)
-
+
##################
# merge two short <td>s
num = 1
@@ -361,7 +361,7 @@
# add a new line if first is * or #
newTable = re.sub("[\r\n]+\| ([*#]{1})",
r"\r\n|\r\n\1", newTable)
-
+
##################
# strip <center> from <th>
newTable =
re.sub("([\r\n]+\![^\r\n]+?)<center>([\w\W]+?)<\/center>",
@@ -373,14 +373,14 @@
# if there are other attributes, simply strip the align="center"
newTable =
re.sub("([\r\n]+\![^\r\n\|]+?)align\=\"center\"([^\n\r\|]+?\|)",
r"\1 \2", newTable)
-
+
##################
# kill additional spaces within arguments
num = 1
while num != 0:
newTable, num = re.subn("[\r\n]+(\||\!)([^|\r\n]*?)[
\t]{2,}([^\r\n]+?)",
r"\r\n\1\2 \3", newTable)
-
+
##################
# I hate those long lines because they make a wall of letters
# Off by default, set 'splitLongParagraphs = True' in user-config.py
@@ -531,7 +531,7 @@
def run(self):
for page in self.generator:
self.treat(page)
-
+
def main():
quietMode = False # use -quiet to get less output
# if the -file argument is used, page titles are stored in this array.
Modified: trunk/pywikipedia/template.py
===================================================================
--- trunk/pywikipedia/template.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/template.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -110,7 +110,7 @@
templates
* xmlfilename - The dump's path, either absolute or relative
"""
-
+
self.templates = templates
self.xmlfilename = xmlfilename
@@ -189,7 +189,7 @@
'ru':u'Робот: замена шаблонов: %s',
'zh':u'機器人: 更改模板 %s',
}
-
+
# Summary messages for removing templates
msg_remove={
'ar':u'روبوت: إزالة القالب: %s',
Modified: trunk/pywikipedia/titletranslate.py
===================================================================
--- trunk/pywikipedia/titletranslate.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/titletranslate.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -14,7 +14,7 @@
def translate(page, hints = None, auto = True):
"""
Please comment your source code! --Daniel
-
+
Does some magic stuff. Returns a list of pages.
"""
result = []
@@ -29,7 +29,7 @@
codes, newname = h.split(':', 1)
if newname == '':
# if given as -hint:xy or -hint:xy:, assume that there should
- # be a page in language xy with the same title as the page
+ # be a page in language xy with the same title as the page
# we're currently working on
ns = page.namespace()
if ns:
@@ -81,18 +81,18 @@
def appendFormatedDates( result, dictName, value ):
for code, func in date.formats[dictName].iteritems():
result.append( u'[[%s:%s]]' % (code,func(value)) )
-
+
def getPoisonedLinks(pl):
"""Returns a list of known corrupted links that should be removed if
seen
"""
result = []
-
+
wikipedia.output( u'getting poisoned links for %s' % pl.title() )
dictName, value = date.getAutoFormat( pl.site().language(), pl.title() )
if dictName is not None:
wikipedia.output( u'date found in %s' % dictName )
-
+
# errors in year BC
if dictName in date.bcFormats:
for fmt in bcDateErrors:
@@ -101,7 +101,7 @@
# i guess this is like friday the 13th for the years
if value == 398 and dictName == 'yearsBC':
appendFormatedDates( result, dictName, 399 )
-
+
if dictName == 'yearsBC':
appendFormatedDates( result, 'decadesBC', value )
appendFormatedDates( result, 'yearsAD', value )
Modified: trunk/pywikipedia/unlink.py
===================================================================
--- trunk/pywikipedia/unlink.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/unlink.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -102,7 +102,7 @@
new = match.group('label') or match.group('title')
new += match.group('linktrail')
return text[:match.start()] + new + text[match.end():], False
-
+
def treat(self, page):
# Show the title of the page we're working on.
# Highlight the title in purple.
Modified: trunk/pywikipedia/upload.py
===================================================================
--- trunk/pywikipedia/upload.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/upload.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -233,7 +233,7 @@
formdata[key] = formdata[key].encode(self.targetSite.encoding())
except (UnicodeEncodeError, UnicodeDecodeError):
formdata[key] =
wikipedia.UnicodeToAsciiHtml(formdata[key]).encode(self.targetSite.encoding())
-
+
# don't upload if we're in debug mode
if not debug:
wikipedia.output(u'Uploading file to %s...' % self.targetSite)
@@ -255,7 +255,7 @@
# something went wrong.
#if response.status in [200, 302]:
# wikipedia.output(u"Upload successful.")
-
+
elif response.status == 301:
wikipedia.output(u"Following redirect...")
address = response.getheader('Location')
Property changes on: trunk/pywikipedia/version.py
___________________________________________________________________
Name: svn:keywords
- Id *.c = svn:eol-style=native *.cpp = svn:eol-style=native *.h = svn:eol-style=native
*.dsp = svn:eol-style=CRLF *.dsw = svn:eol-style=CRLF *.sh = svn:eol-style=native
+ Author Date Id Revision
Modified: trunk/pywikipedia/warnfile.py
===================================================================
--- trunk/pywikipedia/warnfile.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/warnfile.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -15,7 +15,7 @@
# (C) Rob W.W. Hooft, 2003
#
# Distributed under the terms of the MIT license.
-#
+#
__version__ = '$Id$'
#
import sys, os, re
@@ -57,7 +57,7 @@
print "DBG> Failed to add", line
f.close()
return hints, removeHints
-
+
class WarnfileRobot:
def __init__(self, warnfileReader):
self.warnfileReader = warnfileReader
Modified: trunk/pywikipedia/watchlist.py
===================================================================
--- trunk/pywikipedia/watchlist.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/watchlist.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -56,7 +56,7 @@
def isWatched(pageName, site=None):
watchlist = get(site)
return pageName in watchlist
-
+
def refresh(site):
# get watchlist special page's URL
path = site.watchlist_address()
Modified: trunk/pywikipedia/weblinkchecker.py
===================================================================
--- trunk/pywikipedia/weblinkchecker.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/weblinkchecker.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -191,7 +191,7 @@
re.compile('.*[\./(a)]example\.org(/.*)?'))?'),
# Other special cases
- re.compile('.*[\./(a)]gso\.gbv\.de(/.*)?'))?'), # bot somehow can't handle
their redirects
+ re.compile('.*[\./(a)]gso\.gbv\.de(/.*)?'))?'), # bot somehow can't handle
their redirects
re.compile('.*[\./(a)]berlinonline\.de(/.*)?'))?'), # a de: user wants to fix them
by hand and doesn't want them to be deleted, see [[de:Benutzer:BLueFiSH.as/BZ]].
re.compile('.*[\./(a)]bodo\.kommune\.no(/.*)?'))?'), # bot can't handle their
redirects
]
@@ -214,7 +214,7 @@
# ''Please see
http://www.example.org.''
# .'' shouldn't be considered as part of the link.
regex = r'(?P<url>http[s]?://[^' + notInside + ']*?[^' +
notAtEnd + '](?=[' + notAtEnd+ ']*\'\')|http[s]?://[^' + notInside
+ ']*[^' + notAtEnd + '])'
-
+
if withoutBracketed:
regex = r'(?<!\[)' + regex
elif onlyBracketed:
@@ -272,10 +272,10 @@
'''
Given a HTTP URL, tries to load the page from the Internet and checks if it
is still online.
-
+
Returns a (boolean, string) tuple saying if the page is online and including
a status reason.
-
+
Warning: Also returns false if your Internet connection isn't working
correctly! (This will give a Socket Error)
'''
@@ -360,7 +360,7 @@
'''
Requests the header from the server. If the page is an HTTP redirect,
returns the redirect target URL as a string. Otherwise returns None.
-
+
If useHEAD is true, uses the HTTP HEAD method, which saves bandwidth
by not downloading the body. Otherwise, the HTTP GET method is used.
'''
@@ -428,8 +428,8 @@
#
http://docs.python.org/lib/module-socket.html :
# socket.error :
# The accompanying value is either a string telling what went
- # wrong or a pair (errno, string) representing an error
- # returned by a system call, similar to the value
+ # wrong or a pair (errno, string) representing an error
+ # returned by a system call, similar to the value
# accompanying os.error
if isinstance(error, basestring):
msg = error
@@ -499,7 +499,7 @@
# identification for debugging purposes
self.setName((u'%s - %s' % (page.title(), url)).encode('utf-8',
'replace'))
self.HTTPignore = HTTPignore
-
+
def run(self):
linkChecker = LinkChecker(self.url, HTTPignore = self.HTTPignore)
try:
@@ -525,16 +525,16 @@
We assume that the first element in the list represents the first time we
found this dead link, and the last element represents the last time.
-
+
Example:
-
+
dict = {
'http://www.example.org/page': [
('WikiPageTitle', DATE, '404: File not found'),
('WikiPageName2', DATE, '404: File not found'),
]
'''
-
+
def __init__(self, reportThread):
self.reportThread = reportThread
site = wikipedia.getSite()
@@ -622,7 +622,7 @@
return True
else:
return False
-
+
def save(self):
"""
Saves the .dat file to disk.
@@ -643,7 +643,7 @@
self.queue = [];
self.finishing = False
self.killed = False
-
+
def report(self, url, errorReport, containingPage, archiveURL):
"""
Tries to add an error report to the talk page belonging to the page containing
the dead link.
@@ -654,11 +654,11 @@
def shutdown(self):
self.finishing = True
-
+
def kill(self):
# TODO: remove if unneeded
self.killed = True
-
+
def run(self):
while not self.killed:
if len(self.queue) == 0:
Modified: trunk/pywikipedia/welcome.py
===================================================================
--- trunk/pywikipedia/welcome.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/welcome.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -59,8 +59,8 @@
-limit[:#] Use this parameter to define how may users should be
checked (default:50)
- -offset[:TIME] Skip the latest new users (those newer than TIME)
- to give interactive users a chance to welcome the
+ -offset[:TIME] Skip the latest new users (those newer than TIME)
+ to give interactive users a chance to welcome the
new users (default: now)
Timezone is the server timezone, GMT for Wikimedia
TIME format : yyyymmddhhmmss
@@ -220,7 +220,7 @@
summary = {
'commons':u'Welcome!',
'ar':u'مرحبا!',
- 'da':u'Velkommen',
+ 'da':u'Velkommen',
'de':u'Herzlich willkommen!',
'en':u'Welcome!',
'fa':u'خوش آمدید!',
@@ -412,17 +412,17 @@
""" The function to load the users (only users who have a certain
number of edits) """
someone_found = False
autocreated = wsite.mediawiki_message('newuserlog-autocreate-entry')
-
+
# I search with a regex how many user have not the talk page
# and i put them in a list (i find it more easy and secure).
# XXX: That's the regex, if there are problems, take a look here.
-
- reg = u'\(<a href=\"' + re.escape(wsite.path())
+
+ reg = u'\(<a href=\"' + re.escape(wsite.path())
reg +=
u'\?title=%s(?P<user>.*?)&(?:amp;|)action=(?:edit|editredlink|edit&redlink=1)\"'
% talk
reg += u'.*?\) (?P<reason>.*?) . </li>'
p = re.compile(reg, re.UNICODE)
-
+
for x in p.finditer(raw):
someone_found = True
username = x.group('user')
@@ -440,7 +440,7 @@
#FIXME: It counts the first 50 edits
# if number > 50, it won't work
# (not *so* useful, it should be enough).
- contribnum = contribs.count('<li>')
+ contribnum = contribs.count('<li>')
if contribnum >= number:
wikipedia.output(u'%s has enough edits to be welcomed' %
userpage.titleWithoutNamespace() )
@@ -798,7 +798,7 @@
whitelist = list_white + whitelist_default
# think about non-wikimedia wikis. Use Site functions.
- URL = wsite.log_address(limit, 'newusers')
+ URL = wsite.log_address(limit, 'newusers')
if timeoffset_variable != 0:
now = wsite.server_time() - timedelta(minutes=timeoffset_variable)
offset_variable = int(now.strftime("%Y%m%d%H%M%S"))
@@ -858,7 +858,7 @@
else:
final_rep = rep_text
break
- # Checking in the whitelist...
+ # Checking in the whitelist...
for xy in whitelist:
if xy.lower() in lower_uname:
# Deleting the white word found and check
Property changes on: trunk/pywikipedia/welcome.py
___________________________________________________________________
Name: svn:keywords
- Id Author Date Revision
+ Author Date Id Revision
Modified: trunk/pywikipedia/wikicomserver.py
===================================================================
--- trunk/pywikipedia/wikicomserver.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/wikicomserver.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -31,7 +31,7 @@
import sys, os
from win32com.server.util import wrap, unwrap
import win32com.client
-
+
# Although we are able to register our Parent object for debugging,
# our Child object is not registered, so this won't work. To get
# the debugging behavior for our wrapped objects, we must do it ourself.
@@ -70,17 +70,17 @@
site._public_attrs_ = ['objectVer', 'objectName']
site._readonly_attrs_ = site._public_attrs_
return wrap(site, useDispatcher=useDispatcher)
-
+
def getPage(self, site, title):
os.chdir(pywikipediaDir)
siteObj = unwrap(site)
page = WikiPage(siteObj, title)
return wrap(page)
-
+
def __del__(self):
os.chdir(currDir)
print "ChDir to original ", currDir
-
+
class WikiPage(wikipedia.Page):
_reg_clsid_ = "{318CC152-D2A9-4C11-BA01-78B9B91DBDDE}"
_reg_desc_ = "Mediawiki Wiki Page"
@@ -93,7 +93,7 @@
wikipedia.Page.__init__(self, site, title)
self.objectVer = __version__
self.objectName = "WikiPage"
-
+
if __name__=='__main__':
import win32com.server.register
try:
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/wikipedia.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -483,7 +483,7 @@
If underscore is True, replace all ' ' characters with '_'.
If savetitle is True, encode any wiki syntax in the title.
- If decode is True, decodes the section title
+ If decode is True, decodes the section title
"""
title = self._title
if decode:
@@ -801,7 +801,7 @@
pagetext = unescape(pagetext)
pagetext = pagetext.rstrip()
pagetext = self.site().post_get_convert(pagetext)
-
+
m = self.site().redirectRegex().match(pagetext)
if m:
# page text matches the redirect pattern
@@ -1309,7 +1309,7 @@
# happens when arg is unicode
e.reason += ' (cannot convert %s to wiki encoding %s)' %
(msgForError, self.site().encoding())
raise e
-
+
def _putPage(self, text, comment=None, watchArticle=False, minorEdit=True,
newPage=False, token=None, newToken=False, sysop=False,
captchaId=None, captchaAnswer=None ):
@@ -2114,7 +2114,7 @@
throttle=True, deleteAndMove=False, safe=True, fixredirects=True):
"""Move this page to new title given by newtitle. If safe,
don't try
to move and delete if not directly requested.
-
+
* fixredirects has no effect in MW < 1.13"""
# Login
try:
@@ -2746,8 +2746,8 @@
return hash_found
else:
output(u'Image deleted before getting the Hash. Skipping...')
- return None
-
+ return None
+
def getFileVersionHistoryTable(self):
"""Return the version history in the form of a wiki
table."""
lines = []
@@ -3888,7 +3888,7 @@
# Warning! _familyCache does not necessarily have to be consistent between
# two statements. Always ensure that a local reference is created when
-# accessing Family objects
+# accessing Family objects
_familyCache = weakref.WeakValueDictionary()
def Family(fam = None, fatal = True, force = False):
"""
@@ -3899,11 +3899,11 @@
"""
if fam == None:
fam = config.family
-
+
family = _familyCache.get(fam)
if family and not force:
return family
-
+
try:
# search for family module in the 'families' subdirectory
sys.path.append(config.datafilepath('families'))
@@ -3919,7 +3919,7 @@
sys.exit(1)
else:
raise ValueError("Family %s does not exist" % repr(fam))
-
+
family = myfamily.Family()
_familyCache[fam] = family
return family
@@ -4389,7 +4389,7 @@
return response, data
- def getUrl(self, path, retry = True, sysop = False, data = None,
+ def getUrl(self, path, retry = True, sysop = False, data = None,
compress = True, no_hostname = False, cookie_only=False):
"""
Low-level routine to get a URL from the wiki.
@@ -5836,7 +5836,7 @@
def linktrail(self):
"""Return regex for trailing chars displayed as part of a
link."""
return self.family.linktrail(self.lang)
-
+
def post_get_convert(self, getText):
return self.family.post_get_convert(self, getText)
@@ -5885,7 +5885,7 @@
def getImagesFromAnHash(self, hash_found = None):
""" Function that uses APIs to give the images that has the same
hash. Useful
to find duplicates or nowcommons.
-
+
NOTE: it returns also the image itself, if you don't want it, just
filter the list returned.
@@ -6585,15 +6585,15 @@
class MyURLopener(urllib.FancyURLopener):
version="PythonWikipediaBot/1.0"
-
+
def http_error_default(self, url, fp, errcode, errmsg, headers):
if errcode == 401 or errcode == 404:
raise PageNotFound(u'Page %s could not be retrieved. Check your family
file ?' % url)
else:
return urllib.FancyURLopener.http_error_default(self, url, fp, errcode,
errmsg, headers)
-
-
+
+
# Special opener in case we are using a site with authentication
if config.authenticate:
import urllib2, cookielib
Modified: trunk/pywikipedia/wikipediatools.py
===================================================================
--- trunk/pywikipedia/wikipediatools.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/wikipediatools.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -20,7 +20,7 @@
5. If the user-config.py file is not found, another will be created
in the current directory, following in the footsteps of project,
language and bot username.
-
+
"""
for arg in sys.argv[1:]:
if arg.startswith("-dir:"):
Modified: trunk/pywikipedia/wiktionary.py
===================================================================
--- trunk/pywikipedia/wiktionary.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/wiktionary.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -350,7 +350,7 @@
if len(lang)>1 and len(lang)<4:
self.addLink(lang+':'+linkto)
continue
- # store empty lines literally, this necessary for the blocks we don't
parse
+ # store empty lines literally, this necessary for the blocks we don't
parse
# and will return literally
if len(line) <2:
templist.append(line)
@@ -506,7 +506,7 @@
self.addEntry(anentry)
# Then we can easily add this meaning to it.
anentry.addMeaning(ameaning)
-
+
pos=line.find('<!--')
if pos < 4:
# A html comment at the beginning of the line means this
entry already has disambiguation labels, great
Modified: trunk/pywikipedia/wiktionarytest.py
===================================================================
--- trunk/pywikipedia/wiktionarytest.py 2008-08-24 18:20:21 UTC (rev 5845)
+++ trunk/pywikipedia/wiktionarytest.py 2008-08-24 20:53:27 UTC (rev 5846)
@@ -205,7 +205,7 @@
[u'nut', None, u'nuts',
[{'definition': u'A hard-shelled seed', 'concisedef':
u'seed',
'trans': {'nl': u"[[noot]] ''f''",
'fr': u"""''no generic translation exists'';
[[noix]] ''f'' ''is often used, but this actually means
"[[walnut]]"''""", 'de': u"[[Nuss]]
''f''", 'it': u"[[noce]] {{f}}", 'la':
u"[[nux]]"}},
- {'definition': u"A piece of metal, often [[hexagonal]], with a hole
through it with internal threading intended to fit on to a bolt.",
'concisedef': u'that fits on a bolt',
+ {'definition': u"A piece of metal, often [[hexagonal]], with a hole
through it with internal threading intended to fit on to a bolt.",
'concisedef': u'that fits on a bolt',
'trans': {'nl': u"[[moer]] ''f''",
'fr': u"[[écrou]] ''m''", 'de':
u"[[Mutter]] ''f''", 'it': u"[[dado]]
{{m}}"}},
{'definition': u"(''informal'') An insane
person.", 'concisedef': u"'''informal: insane
person'''",
'syns': u"[[loony]], [[nutcase]], [[nutter]]",