Jean-Frédéric has submitted this change and it was merged.
Change subject: Fix flake8 issues
......................................................................
Fix flake8 issues
- Cosmetic PEP8 violations
- unused imports
- E713 test for membership should be 'not in'
Change-Id: I9ee65bc18000ba81f887329be2dba1d2cdcadd4c
---
M erfgoedbot/categorize_images.py
M erfgoedbot/database_statistics.py
M erfgoedbot/missing_commonscat_links.py
M erfgoedbot/monument_tables.py
M erfgoedbot/populate_image_table.py
M erfgoedbot/unused_monument_images.py
M erfgoedbot/update_database.py
7 files changed, 12 insertions(+), 29 deletions(-)
Approvals:
Jean-Frédéric: Verified; Looks good to me, approved
diff --git a/erfgoedbot/categorize_images.py b/erfgoedbot/categorize_images.py
index 29d272a..1110459 100644
--- a/erfgoedbot/categorize_images.py
+++ b/erfgoedbot/categorize_images.py
@@ -15,7 +15,6 @@
python categorize_images.py -countrycode:ee -lang:et
'''
-import sys
import monuments_config as mconfig
import pywikibot
from pywikibot import config
@@ -87,7 +86,7 @@
'ro': (u'Commonscat', [u'Commons cat']),
'ru': (u'Commonscat', [u'Викисклад-кат', u'Commons category']),
'simple': (u'Commonscat',
- [u'Commons cat', u'Commons cat multi', u'Commons category',
+ [u'Commons cat', u'Commons cat multi', u'Commons category',
u'Commons category multi', u'CommonsCompact',
u'Commons-inline']),
'sh': (u'Commonscat', [u'Commons cat']),
@@ -187,7 +186,7 @@
site = pywikibot.Site(u'commons', u'commons')
commonsTemplate = pywikibot.Page(site, 'Template:%s' % commonsTemplateName)
currentcats = list(page.categories())
- if not commonsCategoryBase in currentcats:
+ if commonsCategoryBase not in currentcats:
pywikibot.output(u'%s category not found at: %s. Someone probably
already categorized it.' % (
commonsCategoryBase, page.title()))
return False
@@ -197,7 +196,7 @@
page.title(), commonsCategoryBase))
templates = page.templates()
- if not commonsTemplate in templates:
+ if commonsTemplate not in templates:
pywikibot.output(u'%s template not found at: %s' %
(commonsTemplate, page.title()))
return False
diff --git a/erfgoedbot/database_statistics.py
b/erfgoedbot/database_statistics.py
index 03e4231..9d2dc9a 100755
--- a/erfgoedbot/database_statistics.py
+++ b/erfgoedbot/database_statistics.py
@@ -5,14 +5,10 @@
FIXME: Too much code duplication. Should probably just have one list of the
possible fields for the functions to work on.
'''
-import sys
-import time
import monuments_config as mconfig
import pywikibot
import MySQLdb
from pywikibot import config
-import re
-from pywikibot import pagegenerators
def connectDatabase():
diff --git a/erfgoedbot/missing_commonscat_links.py
b/erfgoedbot/missing_commonscat_links.py
index 7643b54..658eea4 100644
--- a/erfgoedbot/missing_commonscat_links.py
+++ b/erfgoedbot/missing_commonscat_links.py
@@ -11,13 +11,11 @@
python missing_commonscat_links.py -countrycode:XX -lang:YY
'''
-import sys
import monuments_config as mconfig
import pywikibot
from pywikibot import config
import re
import MySQLdb
-import time
def connectDatabase():
@@ -71,7 +69,7 @@
# People can add a /header template for with more info
text = u'{{#ifexist:{{FULLPAGENAME}}/header | {{/header}} }}\n'
- #text = text + u'<gallery>\n'
+ # text = text + u'<gallery>\n'
totalCategories = 0
maxCategories = 1000
@@ -95,7 +93,7 @@
'^[^\?]+\?title\=(.+?)&',
withoutCommonscat.get(monumentId))
wikiSourceList = m.group(1)
categoryName = commonscats.get(catSortKey)
- #pywikibot.output(u'Key %s returned a result' % (monumentId,))
+ # pywikibot.output(u'Key %s returned a result' % (monumentId,))
# pywikibot.output(wikiSourceList)
# pywikibot.output(imageName)
if totalCategories <= maxCategories:
@@ -105,7 +103,7 @@
except ValueError:
pywikibot.output(u'Got value error for %s' % (monumentId,))
- #text = text + u'</gallery>'
+ # text = text + u'</gallery>'
if totalCategories >= maxCategories:
text = text + \
diff --git a/erfgoedbot/monument_tables.py b/erfgoedbot/monument_tables.py
index dac386f..a2a2dbb 100755
--- a/erfgoedbot/monument_tables.py
+++ b/erfgoedbot/monument_tables.py
@@ -5,11 +5,8 @@
Author: Platonides
'''
-import sys
-import time
-import warnings
+
import monuments_config as mconfig
-#import wikipedia, MySQLdb, config, re, pagegenerators
def processCountry(countrycode, lang, countryconfig):
diff --git a/erfgoedbot/populate_image_table.py
b/erfgoedbot/populate_image_table.py
index 36a8b3c..782939f 100644
--- a/erfgoedbot/populate_image_table.py
+++ b/erfgoedbot/populate_image_table.py
@@ -27,14 +27,11 @@
python populate_image_table.py -countrycode:xx
'''
-import sys
import warnings
import monuments_config as mconfig
import pywikibot
from pywikibot import config
-import re
import MySQLdb
-import time
def connectDatabase():
@@ -64,7 +61,7 @@
sources = {}
for (icountrycode, lang), countryconfig in mconfig.countries.iteritems():
if not countrycode or (countrycode and countrycode == icountrycode):
- if not icountrycode in sources:
+ if icountrycode not in sources:
if countryconfig.get('commonsTemplate') and
countryconfig.get('commonsTrackerCategory'):
sources[icountrycode] = {
'commonsTemplate':
countryconfig.get('commonsTemplate'),
@@ -114,7 +111,7 @@
# Remove leading underscors.
monumentId = monumentId.lstrip(u'_')
# All uppercase, same happens in other list
- #monumentId = monumentId.upper()
+ # monumentId = monumentId.upper()
updateImage(countrycode, monumentId, name, conn, cursor)
except UnicodeDecodeError:
diff --git a/erfgoedbot/unused_monument_images.py
b/erfgoedbot/unused_monument_images.py
index cc49983..578e4f8 100644
--- a/erfgoedbot/unused_monument_images.py
+++ b/erfgoedbot/unused_monument_images.py
@@ -11,13 +11,11 @@
python unused_monument_images.py -countrycode:XX -lang:YY
'''
-import sys
import monuments_config as mconfig
import pywikibot
from pywikibot import config
import re
import MySQLdb
-import time
def connectDatabase():
diff --git a/erfgoedbot/update_database.py b/erfgoedbot/update_database.py
index 73bc1f7..cde3532 100755
--- a/erfgoedbot/update_database.py
+++ b/erfgoedbot/update_database.py
@@ -11,8 +11,6 @@
python update_database.py -countrycode:XX -lang:YY
'''
-import sys
-import time
import warnings
import datetime
import monuments_config as mconfig
@@ -135,7 +133,7 @@
return True
-def checkLon(lon, monumentKey, countryconfig, sourcePage):
+def checkLon(lon, monumentKey, countryconfig, sourcePage):
if len(lon):
try:
lon = float(lon)
@@ -225,7 +223,7 @@
cyear = datetime.datetime.now().year
try:
dyear = int(dyear)
- if (dyear+70) < cyear:
+ if (dyear + 70) < cyear:
return u'pd'
else:
return u'noFoP'
@@ -492,7 +490,7 @@
# the time
pregenerator = pagegenerators.PreloadingGenerator(filteredGen)
begintime = datetime.datetime.utcnow(
- ) + datetime.timedelta(days=0-daysBack)
+ ) + datetime.timedelta(days=0 - daysBack)
generator = pagegenerators.EdittimeFilterPageGenerator(
pregenerator, begintime=begintime)
--
To view, visit https://gerrit.wikimedia.org/r/235653
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9ee65bc18000ba81f887329be2dba1d2cdcadd4c
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/heritage
Gerrit-Branch: master
Gerrit-Owner: Jean-Frédéric <[email protected]>
Gerrit-Reviewer: Jean-Frédéric <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits