Skip to content

Commit 90e6315

Browse files
author
xqt
committed
some minor PEP8 changes
1 parent 609d8a4 commit 90e6315

9 files changed

+50
-41
lines changed

apispec.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def iso(t):
4343

4444
def uniso(timestamp):
4545
"""Removes T and Z from an ISO 8601-formatted text for readability."""
46-
return timestamp.replace('T',' ').replace('Z','')
46+
return timestamp.replace('T', ' ').replace('Z', '')
4747

4848
def dt(timestamp):
4949
"""Converts a MediaWiki timestamp to a Python-compatible datetime object"""
@@ -212,7 +212,7 @@ class Blocks(object):
212212
#################################################
213213
def __init__(self, site=site, top='new', limit=5000):
214214
self.site = site
215-
self.bkdir = ['older','newer'][top=='old'] #a bit strange
215+
self.bkdir = ['older', 'newer'][top=='old'] #a bit strange
216216
# bkdir: Direction to list in.
217217
#older: List newest blocks first (default).
218218
#Note: bkstart has to be later than bkend.
@@ -439,8 +439,8 @@ def display(self, block):
439439
or e-mail it or insert into a wikipage with <pre>.
440440
"""
441441
w = 21 #width for justification
442-
flags = ['automatic','anononly','nocreate','autoblock','noemail',
443-
'allowusertalk','hidden']
442+
flags = ['automatic', 'anononly', 'nocreate', 'autoblock', 'noemail',
443+
'allowusertalk', 'hidden']
444444
s = 'Data for block #%s' % block['id']
445445
s += '\nBlocked user:'.ljust(w)
446446
try:
@@ -455,8 +455,8 @@ def display(self, block):
455455
(block['rangestart'],block['rangeend'])
456456
s += '\nAdmin:'.ljust(w) + '%s (#%s)' % (block['by'], block['byid'])
457457
s += '\nBeginning in UTC:'.ljust(w) + uniso(block['timestamp'])
458-
s += (
459-
'\nExpiry%s:' % ['',' in UTC'][block['expiry'][0].isdigit()]).ljust(w)
458+
s += ('\nExpiry%s:' \
459+
% ['', ' in UTC'][block['expiry'][0].isdigit()]).ljust(w)
460460
s += uniso(block['expiry'])
461461
s += '\nFlags:'.ljust(w)
462462
s += ', '.join(filter(lambda x: x in block, flags))

archivebot.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -238,27 +238,30 @@ def feedLine(self, line):
238238
if not TIME:
239239
TIME = txt2timestamp(TM.group(0), "%Y. %B %d., %H:%M (%Z)")
240240
if not TIME:
241-
TIME = txt2timestamp(TM.group(0),"%d. %b %Y kl.%H:%M (%Z)")
241+
TIME = txt2timestamp(TM.group(0), "%d. %b %Y kl.%H:%M (%Z)")
242242
if not TIME:
243-
TIME = txt2timestamp(re.sub(' *\([^ ]+\) *', '', TM.group(0)),"%H:%M, %d %B %Y")
243+
TIME = txt2timestamp(re.sub(' *\([^ ]+\) *', '', TM.group(0)),
244+
"%H:%M, %d %B %Y")
244245
if not TIME:
245-
TIME = txt2timestamp(TM.group(0),"%H:%M, %d %b %Y (%Z)")
246+
TIME = txt2timestamp(TM.group(0), "%H:%M, %d %b %Y (%Z)")
246247
if not TIME:
247-
TIME = txt2timestamp(re.sub(' *\([^ ]+\) *','',TM.group(0)),"%H:%M, %d %b %Y")
248+
TIME = txt2timestamp(re.sub(' *\([^ ]+\) *', '', TM.group(0)),
249+
"%H:%M, %d %b %Y")
248250
if not TIME:
249-
TIME = txt2timestamp(TM.group(0),"%H:%M, %b %d %Y (%Z)")
251+
TIME = txt2timestamp(TM.group(0), "%H:%M, %b %d %Y (%Z)")
250252
if not TIME:
251-
TIME = txt2timestamp(TM.group(0),"%H:%M, %B %d %Y (%Z)")
253+
TIME = txt2timestamp(TM.group(0), "%H:%M, %B %d %Y (%Z)")
252254
if not TIME:
253-
TIME = txt2timestamp(TM.group(0),"%H:%M, %b %d, %Y (%Z)")
255+
TIME = txt2timestamp(TM.group(0), "%H:%M, %b %d, %Y (%Z)")
254256
if not TIME:
255-
TIME = txt2timestamp(TM.group(0),"%H:%M, %B %d, %Y (%Z)")
257+
TIME = txt2timestamp(TM.group(0), "%H:%M, %B %d, %Y (%Z)")
256258
if not TIME:
257259
TIME = txt2timestamp(TM.group(0),"%d. %Bta %Y kello %H.%M (%Z)")
258260
if not TIME:
259-
TIME = txt2timestamp(TM.group(0),"%d %B %Y %H:%M (%Z)")
261+
TIME = txt2timestamp(TM.group(0), "%d %B %Y %H:%M (%Z)")
260262
if not TIME:
261-
TIME = txt2timestamp(re.sub(' *\([^ ]+\) *', '', TM.group(0)), "%H:%M, %d. %b. %Y")
263+
TIME = txt2timestamp(re.sub(' *\([^ ]+\) *', '', TM.group(0)),
264+
"%H:%M, %d. %b. %Y")
262265
if TIME:
263266
self.timestamp = max(self.timestamp, time.mktime(TIME))
264267
## pywikibot.output(u'Time to be parsed: %s' % TM.group(0))
@@ -346,7 +349,7 @@ def update(self, summary, sortThreads = False):
346349
if sortThreads:
347350
pywikibot.output(u'Sorting threads...')
348351
self.threads.sort(key = lambda t: t.timestamp)
349-
newtext = re.sub('\n*$','\n\n',self.header) #Fix trailing newlines
352+
newtext = re.sub('\n*$', '\n\n', self.header) #Fix trailing newlines
350353
for t in self.threads:
351354
newtext += t.toText()
352355
if self.full:
@@ -385,7 +388,7 @@ def get(self, attr, default=''):
385388

386389
def set(self, attr, value, out=True):
387390
if attr == 'archive':
388-
value = value.replace('_',' ')
391+
value = value.replace('_', ' ')
389392
self.attributes[attr] = [value, out]
390393

391394
def saveables(self):
@@ -437,7 +440,7 @@ def feedArchive(self, archive, thread, maxArchiveSize, vars=None):
437440

438441
def analyzePage(self):
439442
maxArchSize = str2size(self.get('maxarchivesize'))
440-
archCounter = int(self.get('counter','1'))
443+
archCounter = int(self.get('counter', '1'))
441444
oldthreads = self.Page.threads
442445
self.Page.threads = []
443446
T = time.mktime(time.gmtime())

blockpageschecker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def understandBlock(text, TTP, TSP, TSMP, TTMP, TU):
192192
def showQuest(site, page):
193193
quest = pywikibot.inputChoice(u'Do you want to open the page?',
194194
['with browser', 'with gui', 'no'],
195-
['b','g','n'], 'n')
195+
['b', 'g', 'n'], 'n')
196196
pathWiki = site.family.nicepath(site.lang)
197197
url = 'http://%s%s%s?&redirect=no' % (pywikibot.getSite().hostname(),
198198
pathWiki, page.urlname())

commonscat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def skipPage(self, page):
320320
else:
321321
for (inPageTemplate, param) in templatesWithParams:
322322
if inPageTemplate == template[0] \
323-
and template[1] in param[0].replace(' ',''):
323+
and template[1] in param[0].replace(' ', ''):
324324
return True
325325
return False
326326

copyright.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
u'Riferimenti bibliografici', u'Collegamenti esterni',
263263
u'Pubblicazioni', u'Pubblicazioni principali',
264264
u'Bibliografia parziale'],
265-
'is': [u'Heimildir', u'Tenglar', u'Tengt efni'],
265+
'is': [u'Heimildir', u'Tenglar', u'Tengt efni'],
266266
'ja': [u'脚注', u'脚注欄', u'脚注・出典', u'出典', u'注釈'],
267267
'zh': [u'參考文獻', u'参考文献', u'參考資料', u'参考资料', u'資料來源', u'资料来源',
268268
u'參見', u'参见', u'參閱', u'参阅'],
@@ -433,7 +433,7 @@ def dump(self):
433433
def read_file(filename, cut_comment = False, cut_newlines = False):
434434
text = u""
435435

436-
f = codecs.open(filename, 'r','utf-8')
436+
f = codecs.open(filename, 'r', 'utf-8')
437437
text = f.read()
438438
f.close()
439439

@@ -742,12 +742,14 @@ def add_in_urllist(self, url, add_item, engine, cache_url = None):
742742
comment.append('[http://www.google.com/search?sourceid=navclient&q=cache:%s Google cache]' % urllib.quote(short_url(add_item)))
743743
elif engine == 'yahoo':
744744
#cache = False
745-
#comment.append('[%s Yahoo cache]' % re.sub('&appid=[^&]*','', urllib2.unquote(cache_url)))
745+
#comment.append('[%s Yahoo cache]' % re.sub('&appid=[^&]*', '', urllib2.unquote(cache_url)))
746746
comment.append("''Yahoo cache''")
747747
elif engine == 'msn':
748-
comment.append('[%s Live cache]' % re.sub('&lang=[^&]*','', cache_url))
748+
comment.append('[%s Live cache]'
749+
% re.sub('&lang=[^&]*', '', cache_url))
749750
else:
750-
comment.append('[http://web.archive.org/*/%s archive.org]' % short_url(add_item))
751+
comment.append('[http://web.archive.org/*/%s archive.org]'
752+
% short_url(add_item))
751753

752754
for i in range(len(url)):
753755
if add_item in url[i]:

featured.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def featuredWithInterwiki(fromsite, tosite, template_on_top, pType, quiet,
476476
if (not interactive or
477477
pywikibot.input(
478478
u'Connecting %s -> %s. Proceed? [Y/N]'
479-
% (a.title(), atrans.title())) in ['Y','y']
479+
% (a.title(), atrans.title())) in ['Y', 'y']
480480
):
481481
m=re_this_iw.search(text)
482482
if not m:
@@ -521,7 +521,7 @@ def featuredWithInterwiki(fromsite, tosite, template_on_top, pType, quiet,
521521
if (not interactive or
522522
pywikibot.input(
523523
u'Connecting %s -> %s. Proceed? [Y/N]'
524-
% (a.title(), atrans.title())) in ['Y','y']
524+
% (a.title(), atrans.title())) in ['Y', 'y']
525525
):
526526
m=re_this_iw.search(text)
527527
if not m:

gui.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ def __init__(self, master=None, **kwargs):
4343
'hilite', fgBg='bg'),
4444
insertbackground=idleConf.GetHighlight(currentTheme,
4545
'cursor', fgBg='fg'),
46-
width=idleConf.GetOption('main','EditorWindow','width'),
47-
height=idleConf.GetOption('main','EditorWindow','height')
46+
width=idleConf.GetOption('main', 'EditorWindow', 'width'),
47+
height=idleConf.GetOption('main', 'EditorWindow',
48+
'height')
4849
)
4950
fontWeight = 'normal'
5051
if idleConf.GetOption('main', 'EditorWindow', 'font-bold', type='bool'):

imagerecat.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ def getCommonshelperCats(imagepage):
167167
if (matches.group('catnum') > 0):
168168
cats = matches.group('cats').splitlines()
169169
for cat in cats:
170-
commonshelperCats.append(cat.replace('_',' '))
170+
commonshelperCats.append(cat.replace('_', ' '))
171171
pywikibot.output(u'category : ' + cat)
172172
if (matches.group('galnum') > 0):
173173
gals = matches.group('gals').splitlines()
174174
for gal in gals:
175-
galleries.append(gal.replace('_',' '))
175+
galleries.append(gal.replace('_', ' '))
176176
pywikibot.output(u'gallery : ' + gal)
177177
commonshelperCats = list(set(commonshelperCats))
178178
galleries = list(set(galleries))
@@ -352,15 +352,14 @@ def filterCountries(categories):
352352
result.append(subcategory.title(withNamespace=False))
353353
return list(set(result))
354354

355-
356355
def filterParents(categories):
357356
''' Remove all parent categories from the set to prevent overcategorization.
358357
359358
'''
360359
result = []
361360
toFilter = u''
362361
for cat in categories:
363-
cat = cat.replace('_',' ')
362+
cat = cat.replace('_', ' ')
364363
toFilter = toFilter + "[[Category:" + cat + "]]\n"
365364
parameters = urllib.urlencode({'source' : toFilter.encode('utf-8'),
366365
'bot' : '1'})

wikipedia.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -3567,7 +3567,7 @@ def loadDeletedRevisions(self, step=None, total=None):
35673567
'list': 'deletedrevs',
35683568
'drfrom': self.title(withNamespace=False),
35693569
'drnamespace': self.namespace(),
3570-
'drprop': ['revid','user','comment','content'],#','minor','len','token'],
3570+
'drprop': ['revid', 'user', 'comment', 'content'], # ,'minor', 'len', 'token'],
35713571
'drlimit': 100,
35723572
'drdir': 'older',
35733573
#'': '',
@@ -4645,10 +4645,14 @@ def globalUsage(self):
46454645
#FIXME : Should have a cleaner way to get the wiki where the image is used
46464646
siteparts = gu['wiki'].split('.')
46474647
if len(siteparts)==3:
4648-
if siteparts[0] in self.site().fam().alphabetic and siteparts[1] in ['wikipedia', 'wiktionary', 'wikibooks', 'wikiquote','wikisource']:
4648+
if siteparts[0] in self.site().fam().alphabetic and \
4649+
siteparts[1] in ['wikipedia', 'wiktionary',
4650+
'wikibooks', 'wikiquote',
4651+
'wikisource']:
46494652
code = siteparts[0]
46504653
fam = siteparts[1]
4651-
elif siteparts[0] in ['meta', 'incubator'] and siteparts[1]==u'wikimedia':
4654+
elif siteparts[0] in ['meta', 'incubator'] and \
4655+
siteparts[1] == u'wikimedia':
46524656
code = code = siteparts[0]
46534657
fam = code = siteparts[0]
46544658
else:
@@ -4824,7 +4828,7 @@ def oneDone(self, entry):
48244828
if not successful:
48254829
output(u"BUG>> title %s (%s) not found in list" % (title, page))
48264830
output(u'Expected one of: %s'
4827-
% u','.join([unicode(page2) for page2 in self.pages]))
4831+
% u', '.join([unicode(page2) for page2 in self.pages]))
48284832
raise PageNotFound
48294833

48304834
def headerDone(self, header):
@@ -4992,7 +4996,7 @@ def oneDoneApi(self, data):
49924996
if not successful:
49934997
output(u"BUG>> title %s (%s) not found in list" % (title, page))
49944998
output(u'Expected one of: %s'
4995-
% u','.join([unicode(page2) for page2 in self.pages]))
4999+
% u', '.join([unicode(page2) for page2 in self.pages]))
49965000
raise PageNotFound
49975001

49985002
def headerDoneApi(self, header):
@@ -6695,7 +6699,7 @@ def _load(self, sysop = False, force = False):
66956699
params = {
66966700
'action': 'query',
66976701
'meta': 'userinfo',
6698-
'uiprop': ['blockinfo','groups','rights','hasmsg'],
6702+
'uiprop': ['blockinfo', 'groups', 'rights', 'hasmsg'],
66996703
}
67006704
if self.versionnumber() >= 12:
67016705
params['uiprop'].append('ratelimits')
@@ -6846,7 +6850,7 @@ def logpages(self, number = 50, mode = '', title = None, user = None, repeat = F
68466850
@deprecate_arg("get_redirect", None) #20120822
68476851
def newpages(self, user=None, returndict=False,
68486852
number=10, repeat=False, namespace=0,
6849-
rcshow = ['!bot','!redirect']):
6853+
rcshow = ['!bot', '!redirect']):
68506854
"""Yield new articles (as Page objects) from recent changes.
68516855
68526856
Starts with the newest article and fetches the number of articles

0 commit comments

Comments
 (0)