http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9482
Revision: 9482
Author: xqt
Date: 2011-08-29 16:32:37 +0000 (Mon, 29 Aug 2011)
Log Message:
-----------
remove trailing whitespaces; update copyright string
Modified Paths:
--------------
trunk/pywikipedia/blockpageschecker.py
trunk/pywikipedia/catlib.py
trunk/pywikipedia/checkimages.py
trunk/pywikipedia/data_ingestion.py
trunk/pywikipedia/imagecopy.py
trunk/pywikipedia/imagecopy_self.py
trunk/pywikipedia/imagerecat.py
trunk/pywikipedia/imagetransfer.py
trunk/pywikipedia/imageuncat.py
trunk/pywikipedia/nowcommons.py
trunk/pywikipedia/saveHTML.py
trunk/pywikipedia/splitwarning.py
trunk/pywikipedia/tag_nowcommons.py
trunk/pywikipedia/weblinkchecker.py
trunk/pywikipedia/welcome.py
Modified: trunk/pywikipedia/blockpageschecker.py
===================================================================
--- trunk/pywikipedia/blockpageschecker.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/blockpageschecker.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -54,7 +54,7 @@
"""
#
# (C) Monobi a.k.a. Wikihermit, 2007
-# (C) Filnik, 2007-2010
+# (C) Filnik, 2007-2011
# (C) NicDumZ, 2008-2009
# (C) Pywikipedia bot team, 2007-2010
#
Modified: trunk/pywikipedia/catlib.py
===================================================================
--- trunk/pywikipedia/catlib.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/catlib.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -9,6 +9,7 @@
# (C) Russell Blau, 2005
# (C) Cyde Weys, 2005-2007
# (C) Leonardo Gregianin, 2005-2007
+# (C) Pywikipedia bot team, 2007-2011
#
# Distributed under the terms of the MIT license.
#
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/checkimages.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -275,7 +275,7 @@
'commons':u"\n{{subst:User:Filnik/untagged|File:%s}}\n\n''This
message was '''added automatically by " + \
"__botnick__''', if you need some help about it, please
read the text above again and follow the links in it," + \
"if you still need help ask at the
[[File:Human-help-browser.svg|18px|link=Commons:Help desk|?]]
'''[[Commons:Help desk|->]]" + \
- "[[Commons:Help desk]]''' in any language you like to
use.'' --__botnick__ ~~~~~""",
+ "[[Commons:Help desk]]''' in any language you like to
use.'' --__botnick__ ~~~~~""",
'ar' :u"{{subst:مصدر الصورة|File:%s}} --~~~~",
'de' :u'\n{{subst:Benutzer:ABF/D2|%s}} ~~~~ ',
'en' :u"{{subst:image source|File:%s}} --~~~~",
Modified: trunk/pywikipedia/data_ingestion.py
===================================================================
--- trunk/pywikipedia/data_ingestion.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/data_ingestion.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -29,21 +29,21 @@
configuration['csvDialect']=u'excel'
configuration['csvDelimiter']=';'
configuration['csvEncoding']=u'Windows-1252' #FIXME: Encoding
hell
-
+
templates = configurationPage.templatesWithParams()
for (template, params) in templates:
if template==u'Data ingestion':
for param in params:
(field, sep, value) = param.partition(u'=')
-
+
# Remove leading or trailing spaces
field = field.strip()
value = value.strip()
configuration[field] = value
- print configuration
+ print configuration
return configuration
-
+
def downloadPhoto(self, photoUrl = ''):
'''
Download the photo and store it in a StrinIO.StringIO object.
@@ -72,9 +72,9 @@
for key, value in metadata.iteritems():
description = description + u'|' + key + u'=%(' + key +
u')s\n'
description = description + u'}}\n'
-
+
return description % metadata
-
+
def getTitle(self, metadata):
'''
Build a title.
@@ -92,7 +92,7 @@
description = description[0 : 120]
title = u'%s - %s.jpg' % (description, identifier)
-
+
return flickrripper.cleanUpTitle(title)
def cleanDate(self, field):
@@ -131,9 +131,9 @@
description = self.getDescription(metadata)
- pywikibot.output(u'Preparing upload for %s.' % title)
- pywikibot.output(description)
-
+ pywikibot.output(u'Preparing upload for %s.' % title)
+ pywikibot.output(description)
+
bot = upload.UploadRobot(url=fileLocation, description=description,
useFilename=title, keepFilename=True, verifyDescription=False, targetSite = self.site)
bot.run()
@@ -145,7 +145,7 @@
for row in reader:
self.metadataCSV(row)
self.processFile(metadata)
-
+
def run(self):
'''
Do crap
@@ -153,15 +153,15 @@
if not self.configuration.get('sourceFormat'):
pywikibot.output(u'The field "sourceFormat" is not set')
return False
-
+
if self.configuration.get('sourceFormat')==u'csv':
self.processCSV()
else:
pywikibot.output(u'%s is not a supported source format')
-
+
def main(args):
generator = None;
-
+
genFactory = pagegenerators.GeneratorFactory()
for arg in pywikibot.handleArgs():
@@ -174,7 +174,7 @@
for page in generator:
bot = DataIngestionBot(page)
bot.run()
-
+
if __name__ == "__main__":
try:
main(sys.argv[1:])
Modified: trunk/pywikipedia/imagecopy.py
===================================================================
--- trunk/pywikipedia/imagecopy.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/imagecopy.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -286,7 +286,7 @@
#If the image is uploaded under a different name, replace all instances
if self.imagePage.titleWithoutNamespace() != self.newname:
moveSummary = i18n.twtranslate(self.imagePage.site(),
'commons-file-moved', {'localfile' :
self.imagePage.titleWithoutNamespace(), 'commonsfile' : self.newname})
-
+
imagebot = ImageRobot(generator = self.preloadingGen, oldImage =
self.imagePage.titleWithoutNamespace(), newImage = self.newname, summary = moveSummary,
always = True, loose = True)
imagebot.run()
return
Modified: trunk/pywikipedia/imagecopy_self.py
===================================================================
--- trunk/pywikipedia/imagecopy_self.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/imagecopy_self.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -237,7 +237,7 @@
return False
return True
-
+
class imageFetcher(threading.Thread):
'''
Tries to fetch information for all images in the generator
@@ -519,14 +519,14 @@
self.uploadQueue.put(None)
pywikibot.output(u'User worked on all images.')
return True
-
+
def setAutonomous(self):
'''
Don't do any user interaction.
'''
self.autonomous = True
return
-
+
def processImage(self, fields):
'''
Work on a single image
@@ -604,7 +604,7 @@
self.information_author_label = Label(self.root, text=u'Author : ')
self.information_permission_label = Label(self.root, text=u'Permission :
')
self.information_other_versions_label = Label(self.root, text=u'Other
versions : ')
-
+
self.information_licensetemplate_label = Label(self.root,
text=u'License : ')
self.information_categories_label = Label(self.root,
@@ -923,7 +923,7 @@
if autonomous:
pywikibot.output(u'Bot is running in autonomous mode. There will be no user
interaction.')
userInteractionThread.setAutonomous()
-
+
if not checkTemplate:
pywikibot.output(u'No check template will be added to the uploaded
files.')
uploaderThread.nochecktemplate()
Modified: trunk/pywikipedia/imagerecat.py
===================================================================
--- trunk/pywikipedia/imagerecat.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/imagerecat.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -26,7 +26,8 @@
"""
__version__ = '$Id$'
#
-# (C) Multichill 2008
+# (C) Multichill 2008-2011
+# (C) Pywikipedia bot team, 2008-2011
#
# Distributed under the terms of the MIT license.
#
Modified: trunk/pywikipedia/imagetransfer.py
===================================================================
--- trunk/pywikipedia/imagetransfer.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/imagetransfer.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -24,6 +24,7 @@
"""
#
# (C) Andre Engels, 2004
+# (C) Pywikipedia bot team, 2004-2011
#
# Distributed under the terms of the MIT license.
#
Modified: trunk/pywikipedia/imageuncat.py
===================================================================
--- trunk/pywikipedia/imageuncat.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/imageuncat.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -6,7 +6,8 @@
"""
__version__ = '$Id$'
#
-# (C) Multichill 2008
+# (C) Multichill 2008-2011
+# (C) Pywikipedia bot team, 2008-2011
#
# Distributed under the terms of the MIT license.
#
Modified: trunk/pywikipedia/nowcommons.py
===================================================================
--- trunk/pywikipedia/nowcommons.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/nowcommons.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -48,6 +48,7 @@
#
# (C) Wikipedian, 2006-2007
# (C) Siebrand Mazeland, 2007
+# (C) Pywikipedia bot team, 2006-2011
#
# Distributed under the terms of the MIT license.
#
Modified: trunk/pywikipedia/saveHTML.py
===================================================================
--- trunk/pywikipedia/saveHTML.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/saveHTML.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -23,12 +23,14 @@
"""
# (C) 2004 Thomas R. Koll, <tomk32(a)tomk32.de>
+# (C) Pywikipedia bot team, 2004-2011
#
# Distributed under the terms of the MIT license.
#
__version__ = '$Id$'
-import wikipedia,httplib,StringIO,re,sys,md5,os, string
+import httplib, StringIO, re, sys, md5, os, string
+import wikipedia as pywikibot
from htmlentitydefs import *
def extractArticle(data):
@@ -124,14 +126,14 @@
def main():
- mysite = wikipedia.getSite()
+ mysite = pywikibot.getSite()
sa = []
output_directory = ""
save_images = False
overwrite_images = False
overwrite_articles = False
- for arg in wikipedia.handleArgs():
+ for arg in pywikibot.handleArgs():
if arg.startswith("-lang:"):
lang = arg[6:]
elif arg.startswith("-file:"):
@@ -162,7 +164,7 @@
sa.append(arg.replace(" ", "_"))
headers = {"Content-type": "application/x-www-form-urlencoded",
- "User-agent": wikipedia.useragent}
+ "User-agent": pywikibot.useragent}
print "opening connection to", mysite.hostname(),
conn = httplib.HTTPConnection(mysite.hostname())
print " done"
@@ -200,14 +202,14 @@
print "skipping existing " + i['image']
continue
print 'downloading ' + i['image'],
- uo = wikipedia.MyURLopener
+ uo = pywikibot.MyURLopener
file = uo.open( "http://upload.wikimedia.org/wikipedia/"
+mysite.lang + '/' + i['path'] +
i['image'])
content = file.read()
if (len(content) < 500):
uo.close()
print "downloading from commons",
- uo = wikipedia.MyURLopener
+ uo = pywikibot.MyURLopener
file = uo.open( "http://commons.wikimedia.org/upload/"
+ i['path'] + i['image'])
#print "http://commons.wikimedia.org/upload/",
i['path'] , i['image'], file
Modified: trunk/pywikipedia/splitwarning.py
===================================================================
--- trunk/pywikipedia/splitwarning.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/splitwarning.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -2,22 +2,23 @@
"""Splits a interwiki.log file into chunks of warnings separated by
language"""
#
# (C) Rob W.W. Hooft, 2003
+# (C) Pywikipedia bot team, 2004-2011
#
# Distributed under the terms of the MIT license.
#
__version__ = '$Id$'
#
-import wikipedia
+import wikipedia as pywikibot
import codecs
import re
-wikipedia.stopme() # No need to have me on the stack - I don't contact the wiki
+pywikibot.stopme() # No need to have me on the stack - I don't contact the wiki
files={}
count={}
# TODO: Variable log filename
-fn = wikipedia.config.datafilepath("logs", "interwiki.log")
+fn = pywikibot.config.datafilepath("logs", "interwiki.log")
logFile = codecs.open(fn, 'r', 'utf-8')
rWarning = re.compile('WARNING: (?P<family>.+?):
\[\[(?P<code>.+?):.*')
for line in logFile:
@@ -25,10 +26,10 @@
if m:
family = m.group('family')
code = m.group('code')
- if code in wikipedia.getSite().languages():
+ if code in pywikibot.getSite().languages():
if not code in files:
files[code] = codecs.open(
- wikipedia.config.datafilepath('logs',
+ pywikibot.config.datafilepath('logs',
'warning-%s-%s.log' % (family, code)),
'w', 'utf-8')
count[code] = 0
Modified: trunk/pywikipedia/tag_nowcommons.py
===================================================================
--- trunk/pywikipedia/tag_nowcommons.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/tag_nowcommons.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -60,8 +60,8 @@
newtext = imagepage.get() + template % (duplicate,)
pywikibot.showDiff(imagepage.get(), newtext)
imagepage.put(newtext, comment)
-
-
+
+
if __name__ == "__main__":
try:
main(sys.argv[1:])
Modified: trunk/pywikipedia/weblinkchecker.py
===================================================================
--- trunk/pywikipedia/weblinkchecker.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/weblinkchecker.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -88,7 +88,7 @@
#
# (C) Daniel Herding, 2005
-# (C) Pywikipedia bot team, 2005-2010
+# (C) Pywikipedia bot team, 2005-2011
#
# Distributed under the terms of the MIT license.
#
Modified: trunk/pywikipedia/welcome.py
===================================================================
--- trunk/pywikipedia/welcome.py 2011-08-29 15:55:43 UTC (rev 9481)
+++ trunk/pywikipedia/welcome.py 2011-08-29 16:32:37 UTC (rev 9482)
@@ -169,11 +169,12 @@
#
# (C) Alfio, 2005
# (C) Kyle/Orgullomoore, 2006-2007
-# (C) Siebrand Mazeland, 2006-2007
-# (C) Filnik, 2007-2010
+# (C) Siebrand Mazeland, 2006-2009
+# (C) Filnik, 2007-2011
# (C) Daniel Herding, 2007
-# (C) Alex Shih-Han Lin, 2009
+# (C) Alex Shih-Han Lin, 2009-2010
# (C) xqt, 2009-2011
+# (C) Pywikipedia bot team, 2008-2010
#
# Distributed under the terms of the MIT license.
#