jenkins-bot has submitted this change and it was merged.

Change subject: pep8-ified scripts/data_ingestion.py
......................................................................


pep8-ified scripts/data_ingestion.py

Change-Id: I04c5b328e16db2594c6436a68c73cc66ee116ac5
---
M scripts/data_ingestion.py
1 file changed, 16 insertions(+), 11 deletions(-)

Approvals:
  Ladsgroup: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py
index df43f9d..386ff91 100755
--- a/scripts/data_ingestion.py
+++ b/scripts/data_ingestion.py
@@ -5,10 +5,13 @@
 
 '''
 import pywikibot
-import posixpath, urlparse
+import posixpath
+import urlparse
 import urllib
-import hashlib, base64
+import hashlib
+import base64
 import StringIO
+
 
 class Photo(object):
     '''
@@ -36,11 +39,11 @@
         TODO: Add exception handling
         '''
         if not self.contents:
-            imageFile=urllib.urlopen(self.URL).read()
+            imageFile = urllib.urlopen(self.URL).read()
             self.contents = StringIO.StringIO(imageFile)
         return self.contents
 
-    def findDuplicateImages(self, site = pywikibot.getSite(u'commons', 
u'commons')):
+    def findDuplicateImages(self, site=pywikibot.getSite(u'commons', 
u'commons')):
         '''
         Takes the photo, calculates the SHA1 hash and asks the mediawiki api 
for a list of duplicates.
 
@@ -76,12 +79,14 @@
     def _safeTemplateValue(self, value):
         return value.replace("|", "{{!}}")
 
+
 def CSVReader(fileobj, urlcolumn, *args, **kwargs):
     import csv
     reader = csv.DictReader(fileobj, *args, **kwargs)
 
     for line in reader:
         yield Photo(line[urlcolumn], line)
+
 
 class DataIngestionBot:
     def __init__(self, reader, titlefmt, pagefmt, 
site=pywikibot.getSite(u'commons', u'commons')):
@@ -99,12 +104,12 @@
         title = photo.getTitle(self.titlefmt)
         description = photo.getDescription(self.pagefmt)
 
-        bot = upload.UploadRobot(url = photo.URL,
-                                 description = description,
-                                 useFilename = title,
-                                 keepFilename = True,
-                                 verifyDescription = False,
-                                 targetSite = self.site)
+        bot = upload.UploadRobot(url=photo.URL,
+                                 description=description,
+                                 useFilename=title,
+                                 keepFilename=True,
+                                 verifyDescription=False,
+                                 targetSite=self.site)
         bot._contents = photo.downloadPhoto().getvalue()
         bot._retrieved = True
         bot.run()
@@ -118,7 +123,7 @@
         for photo in self.reader:
             self._doUpload(photo)
 
-if __name__=="__main__":
+if __name__ == "__main__":
     reader = CSVReader(open('tests/data/csv_ingestion.csv'), 'url')
     bot = DataIngestionBot(reader, "%(name)s - %(set)s.%(_ext)s", 
":user:valhallasw/test_template", pywikibot.getSite('test', 'test'))
     bot.run()

-- 
To view, visit https://gerrit.wikimedia.org/r/80847
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I04c5b328e16db2594c6436a68c73cc66ee116ac5
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to