jenkins-bot has submitted this change and it was merged.
Change subject: [PEP8] changes
......................................................................
[PEP8] changes
Change-Id: I74c9669c35bb064a2ca65193429bf6c059256e9e
---
M titletranslate.py
1 file changed, 31 insertions(+), 21 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/titletranslate.py b/titletranslate.py
index 8e1a2d5..1fcb892 100644
--- a/titletranslate.py
+++ b/titletranslate.py
@@ -13,12 +13,15 @@
import wikipedia as pywikibot
import date
+
def _join_to_(result, join):
for x in join:
if x not in result:
result.append(x)
-def translate(page, hints=None, auto=True, removebrackets=False, site=None,
family=None):
+
+def translate(page, hints=None, auto=True, removebrackets=False, site=None,
+ family=None):
"""
Goes through all entries in 'hints'. Returns a list of pages.
@@ -50,7 +53,7 @@
# be a page in language xy with the same title as the page
# we're currently working on ...
if page is None:
- continue
+ continue
ns = page.namespace()
if ns:
newname = u'%s:%s' % (family.namespace('_default',
ns),
@@ -60,35 +63,40 @@
newname = page.title()
# ... unless we do want brackets
if removebrackets:
- newname = re.sub(re.compile(ur"\W*?\(.*?\)\W*?",
re.UNICODE), u" ", newname)
+ newname = re.sub(re.compile(ur"\W*?\(.*?\)\W*?",
+ re.UNICODE), u" ", newname)
codesplit = codes.split(',')
codes = []
for code in codesplit:
try:
number = int(code)
- _join_to_(codes, family.languages_by_size[:number] )
+ _join_to_(codes, family.languages_by_size[:number])
except ValueError:
if code == 'all':
- _join_to_(codes, family.languages_by_size )
+ _join_to_(codes, family.languages_by_size)
elif code in family.language_groups:
- _join_to_(codes, family.language_groups[code] )
+ _join_to_(codes, family.language_groups[code])
elif code:
- _join_to_(codes, [ code ] )
+ _join_to_(codes, [code])
for newcode in codes:
x = None
if newcode in family.langs.keys():
if page is None or \
(newcode != sitelang and
- pywikibot.getSite().family.name
- not in family.interwiki_forwarded_from):
- x = pywikibot.Page(pywikibot.getSite(fam=family, code=newcode),
newname)
+ pywikibot.getSite().family.name
+ not in family.interwiki_forwarded_from):
+ x = pywikibot.Page(pywikibot.getSite(fam=family,
+ code=newcode),
+ newname)
elif newcode in family.interwiki_forwarded_from:
- x = pywikibot.Page(pywikibot.getSite(fam=newcode, code=newcode),
newname)
+ x = pywikibot.Page(pywikibot.getSite(fam=newcode,
+ code=newcode), newname)
else:
if pywikibot.verbose:
- pywikibot.output(u"Ignoring the unknown language code
%s" % newcode)
+ pywikibot.output(
+ u"Ignoring the unknown language code %s" %
newcode)
if x:
- _join_to_(result, [ x ] )
+ _join_to_(result, [x])
# Autotranslate dates into all other languages, the rest will come from
# existing interwiki links.
@@ -111,23 +119,25 @@
entryLang in date.maxyearBC and \
value > date.maxyearBC[entryLang]:
pass
- elif dictName == 'yearsAD' and \
- entryLang in date.maxyearAD and \
- value > date.maxyearAD[entryLang]:
+ elif (dictName == 'yearsAD' and
+ entryLang in date.maxyearAD and
+ value > date.maxyearAD[entryLang]):
pass
else:
newname = entry(value)
x = pywikibot.Page(
pywikibot.getSite(code=entryLang,
fam=family), newname)
- _join_to_(result, [ x ] )
+ _join_to_(result, [x])
return result
bcDateErrors = [u'[[ko:%d년]]']
-def appendFormatedDates( result, dictName, value ):
+
+def appendFormatedDates(result, dictName, value):
for code, func in date.formats[dictName].iteritems():
- result.append( u'[[%s:%s]]' % (code,func(value)) )
+ result.append(u'[[%s:%s]]' % (code, func(value)))
+
def getPoisonedLinks(pl):
"""Returns a list of known corrupted links that should be removed if
seen
@@ -137,11 +147,11 @@
pywikibot.output(u'getting poisoned links for %s' % pl.title())
dictName, value = date.getAutoFormat(pl.site.language(), pl.title())
if dictName is not None:
- pywikibot.output( u'date found in %s' % dictName )
+ pywikibot.output(u'date found in %s' % dictName)
# errors in year BC
if dictName in date.bcFormats:
for fmt in bcDateErrors:
- result.append( fmt % value )
+ result.append(fmt % value)
# i guess this is like friday the 13th for the years
if value == 398 and dictName == 'yearsBC':
appendFormatedDates(result, dictName, 399)
--
To view, visit
https://gerrit.wikimedia.org/r/98104
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I74c9669c35bb064a2ca65193429bf6c059256e9e
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot