http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10513
Revision: 10513 Author: xqt Date: 2012-09-04 08:30:37 +0000 (Tue, 04 Sep 2012) Log Message: ----------- The "keep_name" never gets assigned, patch bug #3564485 to fix it; md5, haslib, urllib removed: no longer used since r2501; some PEP8 changes;
Modified Paths: -------------- trunk/pywikipedia/imagetransfer.py
Modified: trunk/pywikipedia/imagetransfer.py =================================================================== --- trunk/pywikipedia/imagetransfer.py 2012-09-01 11:27:48 UTC (rev 10512) +++ trunk/pywikipedia/imagetransfer.py 2012-09-04 08:30:37 UTC (rev 10513) @@ -26,13 +26,13 @@ """ # # (C) Andre Engels, 2004 -# (C) Pywikipedia bot team, 2004-2011 +# (C) Pywikipedia bot team, 2004-2012 # # Distributed under the terms of the MIT license. # __version__='$Id$'
-import re, sys, md5, urllib +import re, sys import wikipedia as pywikibot import upload, config, pagegenerators
@@ -177,10 +177,12 @@ and uploads it to another wikipedia. Returns the filename which was used to upload the image This function is used by imagetransfer.py and by copy_table.py + """ sourceSite = sourceImagePage.site() - if debug: print "-" * 50 - if debug: print "Found image: %s"% imageTitle + if debug: + print "-" * 50 + print "Found image: %s"% imageTitle url = sourceImagePage.fileUrl().encode('utf-8') pywikibot.output(u"URL should be: %s" % url) # localize the text that should be printed on the image description page @@ -188,7 +190,8 @@ description = sourceImagePage.get() # try to translate license templates if (sourceSite.sitename(), self.targetSite.sitename()) in licenseTemplates: - for old, new in licenseTemplates[(sourceSite.sitename(), self.targetSite.sitename())].iteritems(): + for old, new in licenseTemplates[(sourceSite.sitename(), + self.targetSite.sitename())].iteritems(): new = '{{%s}}' % new old = re.compile('{{%s}}' % old) description = pywikibot.replaceExcept(description, old, new, @@ -202,10 +205,10 @@ if sourceSite.family == self.targetSite.family: description += "\r\n\r\n" + unicode(sourceImagePage) except pywikibot.NoPage: - description='' + description = '' print "Image does not exist or description page is empty." except pywikibot.IsRedirectPage: - description='' + description = '' print "Image description page is redirect." else: bot = upload.UploadRobot(url=url, description=description, @@ -239,7 +242,7 @@ for i in range(len(imagelist)): image = imagelist[i] #sourceSite = sourceImagePage.site() - print "-"*60 + print "-" * 60 pywikibot.output(u"%s. Found image: %s" % (i, image.title(asLink=True))) try: @@ -257,7 +260,7 @@ targetImage.get(throttle=False) pywikibot.output(u"Image with this name is already on %s." % self.targetSite) - print "-"*60 + print "-" * 60 pywikibot.output(targetImage.get(throttle=False)) sys.exit() except pywikibot.NoPage: @@ -321,7 +324,7 @@ if arg == '-interwiki': interwiki = True elif arg.startswith('-keepname'): - keepname = True + keep_name = True elif arg.startswith('-tolang:'): targetLang = arg[8:] elif arg.startswith('-tofamily:'):
pywikipedia-svn@lists.wikimedia.org