Skip to content

Commit

Permalink
Merge "[PEP8] Keep lines beneath 80 chars"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Jan 13, 2017
2 parents 897bbb3 + 427a82e commit 6be9916
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 81 deletions.
20 changes: 12 additions & 8 deletions scripts/clean_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
# (C) Wikipedian, 2006-2007
# (C) Andre Engels, 2007
# (C) Siebrand Mazeland, 2007
# (C) xqt, 2009-2014
# (C) xqt, 2009-2017
# (C) Dr. Trigon, 2012
# (C) Pywikibot team, 2012-2014
# (C) Pywikibot team, 2012-2017
#
# Distributed under the terms of the MIT license.
#
Expand All @@ -57,7 +57,7 @@
u'حيتم تنضيفها\nاوتوماتيكيا كل 12 ساعه. -->',
'az': u'<!--- LÜTFƏN, BU SƏTRƏ TOXUNMAYIN --->\n{{Qaralama dəftəri}}\n'
u'<!-- AŞAĞIDAKI XƏTTİN ALTINDAN YAZA BİLƏRSİNİZ --->',
'bar': u'{{Bitte erst NACH dieser Zeile schreiben! (Begrüßungskasten)}}\r\n',
'bar': '{{Bitte erst NACH dieser Zeile schreiben! (Begrüßungskasten)}}\n',
'cs': u'{{subst:/uhrabat}}',
'da': u'{{subst:Sandkasse tekst}}',
'de': u'{{subst:Wikipedia:Spielwiese/Vorlage}}',
Expand All @@ -70,7 +70,8 @@
'fi': u'{{subst:Hiekka}}',
'he': u'{{ארגז חול}}\n<!-- נא לערוך מתחת לשורה זו בלבד, תודה. -->',
'id': u'{{Bakpasir}}\n<!-- Uji coba dilakukan di baris di bawah ini -->',
'it': u'{{sandbox}}<!-- Scrivi SOTTO questa riga senza cancellarla. Grazie. -->',
'it': '{{sandbox}}'
'<!-- Scrivi SOTTO questa riga senza cancellarla. Grazie. -->',
'ja': u'{{subst:サンドボックス}}',
'ko': u'{{연습장 안내문}}',
'ksh': u'{{subst:/Schablon}}',
Expand All @@ -86,17 +87,20 @@
'no': u'{{Sandkasse}}\n<!-- VENNLIGST EKSPERIMENTER NEDENFOR DENNE '
u'SKJULTE TEKSTLINJEN! SANDKASSEMALEN {{Sandkasse}} SKAL IKKE '
u'FJERNES! -->}}',
'pl': u'{{Prosimy - NIE ZMIENIAJ, NIE KASUJ, NIE PRZENOŚ tej linijki - pisz niżej}}',
'pt': u'<!--não apague esta linha-->{{página de testes}}<!--não apagar-->\r\n',
'ru': u'{{/Пишите ниже}}\n<!-- Не удаляйте, пожалуйста, эту строку, тестируйте ниже -->',
'pl': '{{Prosimy - NIE ZMIENIAJ, NIE KASUJ, NIE PRZENOŚ tej linijki '
'- pisz niżej}}',
'pt': '<!--não apague esta linha-->'
'{{página de testes}}<!--não apagar-->\n',
'ru': '{{/Пишите ниже}}\n'
'<!-- Не удаляйте, пожалуйста, эту строку, тестируйте ниже -->',
'simple': u'{{subst:/Text}}',
'sco': u'{{subst:Saundbox}}',
'sr': u'{{песак}}\n<!-- Молимо, испробавајте испод ове линије. Хвала. -->',
'sv': u'{{subst:Sandlådan}}',
'th': u'{{กระบะทราย}}\n<!-- กรุณาอย่าแก้ไขบรรทัดนี้ ขอบคุณครับ/ค่ะ -- '
u'Please leave this line as they are. Thank you! -->',
'tr': u'{{/Bu satırı değiştirmeden bırakın}}',
'zh': u'{{subst:User:Sz-iwbot/sandbox}}\r\n',
'zh': '{{subst:User:Sz-iwbot/sandbox}}\n',
}

sandboxTitle = {
Expand Down
14 changes: 8 additions & 6 deletions scripts/commons_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""
#
# (C) Leonardo Gregianin, 2006
# (C) Pywikibot team, 2007-2014
# (C) Pywikibot team, 2007-2016
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -88,16 +88,18 @@ def run(self):
if s or s2:
pywikibot.output(u'** Already done.')
else:
cats = textlib.getCategoryLinks(text, site=page.site)
cats = textlib.getCategoryLinks(text,
site=page.site)
text = textlib.replaceCategoryLinks(
u'%s{{commons%s|%s}}'
% (text, ('', 'cat')[catmode], pagetitle),
cats, site=page.site)
comment = i18n.twtranslate(page.site,
'commons_link%s-template-added'
% ('', '-cat')[catmode])
comment = i18n.twtranslate(
page.site, 'commons_link%s-template-added'
% ('', '-cat')[catmode])
try:
self.userPut(page, oldText, text, summary=comment)
self.userPut(page, oldText, text,
summary=comment)
except pywikibot.EditConflict:
pywikibot.output(
u'Skipping %s because of edit conflict'
Expand Down
4 changes: 2 additions & 2 deletions scripts/coordinate_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
This will work on all pages in the category "coordinates not on Wikidata" and
will import the coordinates on these pages to Wikidata.
The data from the "GeoData" extension (https://www.mediawiki.org/wiki/Extension:GeoData)
The data from the "GeoData" extension (https://www.mediawiki.org/wiki/GeoData)
is used so that extension has to be setup properly. You can look at the
[[Special:Nearby]] page on your local Wiki to see if it's populated.
Expand All @@ -24,7 +24,7 @@
"""
#
# (C) Multichill, 2014
# (C) Pywikibot team, 2013-2015
# (C) Pywikibot team, 2013-2016
#
# Distributed under the terms of MIT License.
#
Expand Down
3 changes: 2 additions & 1 deletion scripts/cosmetic_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def main(*args):
elif ignore_mode == 'match':
options['ignore'] = cosmetic_changes.CANCEL_MATCH
else:
raise ValueError('Unknown ignore mode "{0}"!'.format(ignore_mode))
raise ValueError(
'Unknown ignore mode "{0}"!'.format(ignore_mode))
else:
genFactory.handleArg(arg)

Expand Down
6 changes: 4 additions & 2 deletions scripts/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ def main(*args):
summary = i18n.twtranslate(mysite, 'delete-from-category',
{'page': pageName})
elif arg.startswith('-links'):
summary = i18n.twtranslate(mysite, un + 'delete-linked-pages',
summary = i18n.twtranslate(mysite,
un + 'delete-linked-pages',
{'page': pageName})
elif arg.startswith('-ref'):
summary = i18n.twtranslate(mysite, 'delete-referring-pages',
Expand All @@ -291,7 +292,8 @@ def main(*args):
if generator:
if summary is None:
summary = pywikibot.input(u'Enter a reason for the %sdeletion:'
% ['', 'un'][options.get('undelete', False)])
% ['', 'un'][options.get('undelete',
False)])
bot = DeletionRobot(generator, summary, **options)
bot.run()
return True
Expand Down
11 changes: 7 additions & 4 deletions scripts/freebasemappingupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""
#
# (C) Denny Vrandecic, 2013
# (C) Pywikibot team, 2013-2014
# (C) Pywikibot team, 2013-2016
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -50,10 +50,13 @@ def run(self):
self.claim = pywikibot.Claim(self.repo, 'P646') # freebase mapping
# And sources!
self.statedin = pywikibot.Claim(self.repo, 'P248') # stated in
freebasedumpitem = pywikibot.ItemPage(self.repo, 'Q15241312') # Freebase data dump
# Freebase data dump
freebasedumpitem = pywikibot.ItemPage(self.repo, 'Q15241312')
self.statedin.setTarget(freebasedumpitem)
self.dateofpub = pywikibot.Claim(self.repo, 'P577') # date of publication
oct28 = pywikibot.WbTime(site=self.repo, year=2013, month=10, day=28, precision='day')
# date of publication
self.dateofpub = pywikibot.Claim(self.repo, 'P577')
oct28 = pywikibot.WbTime(site=self.repo, year=2013, month=10, day=28,
precision='day')
self.dateofpub.setTarget(oct28)

for line in gzip.open(self.filename):
Expand Down
29 changes: 18 additions & 11 deletions scripts/harvest_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""
#
# (C) Multichill, Amir, 2013
# (C) Pywikibot team, 2013-2014
# (C) Pywikibot team, 2013-2017
#
# Distributed under the terms of MIT License.
#
Expand Down Expand Up @@ -91,7 +91,8 @@ def getTemplateSynonyms(self, title):
if temp.isRedirectPage():
temp = temp.getRedirectTarget()
titles = [page.title(withNamespace=False)
for page in temp.getReferences(redirectsOnly=True, namespaces=[10],
for page in temp.getReferences(redirectsOnly=True,
namespaces=[10],
follow_redirects=False)]
titles.append(temp.title(withNamespace=False))
return titles
Expand Down Expand Up @@ -180,24 +181,28 @@ def treat(self, page, item):
continue

link_text = match.group(1)
linked_item = self._template_link_target(item, link_text)
linked_item = self._template_link_target(
item, link_text)
if not linked_item:
continue

claim.setTarget(linked_item)
elif claim.type in ('string', 'external-id'):
claim.setTarget(value.strip())
elif claim.type == 'commonsMedia':
commonssite = pywikibot.Site("commons", "commons")
imagelink = pywikibot.Link(value, source=commonssite,
commonssite = pywikibot.Site('commons',
'commons')
imagelink = pywikibot.Link(value,
source=commonssite,
defaultNamespace=6)
image = pywikibot.FilePage(imagelink)
if image.isRedirectPage():
image = pywikibot.FilePage(image.getRedirectTarget())
image = pywikibot.FilePage(
image.getRedirectTarget())
if not image.exists():
pywikibot.output(
'[[%s]] doesn\'t exist so I can\'t link to it'
% (image.title(),))
"{0} doesn't exist. I can't link to it"
''.format(image.title(asLink=True)))
continue
claim.setTarget(image)
else:
Expand All @@ -206,8 +211,9 @@ def treat(self, page, item):
% claim.type)
continue

pywikibot.output('Adding %s --> %s'
% (claim.getID(), claim.getTarget()))
pywikibot.output(
'Adding %s --> %s'
% (claim.getID(), claim.getTarget()))
item.addClaim(claim)
# A generator might yield pages from multiple sites
source = self.getSource(page.site)
Expand Down Expand Up @@ -245,7 +251,8 @@ def main(*args):
commandline_arguments.append(arg)

if not template_title:
pywikibot.error('Please specify either -template or -transcludes argument')
pywikibot.error(
'Please specify either -template or -transcludes argument')
return

if len(commandline_arguments) % 2:
Expand Down
19 changes: 11 additions & 8 deletions scripts/illustrate_wikidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""
#
# (C) Multichill, 2014
# (C) Pywikibot team, 2013-2014
# (C) Pywikibot team, 2013-2016
#
# Distributed under the terms of MIT License.
#
Expand All @@ -38,10 +38,10 @@ def __init__(self, generator, wdproperty=u'P18'):
"""
Constructor.
Arguments:
* generator - A generator that yields Page objects.
* wdproperty - The property to add. Should be of type commonsMedia
@param generator: A generator that yields Page objects
@type generator: generator
@param wdproperty: The property to add. Should be of type commonsMedia
@type wdproperty: str
"""
super(IllustrateRobot, self).__init__()
self.generator = pagegenerators.PreloadingGenerator(generator)
Expand Down Expand Up @@ -71,17 +71,20 @@ def treat(self, page, item):

newclaim = pywikibot.Claim(self.repo, self.wdproperty)
commonssite = pywikibot.Site("commons", "commons")
imagelink = pywikibot.Link(imagename, source=commonssite, defaultNamespace=6)
imagelink = pywikibot.Link(imagename, source=commonssite,
defaultNamespace=6)
image = pywikibot.FilePage(imagelink)
if image.isRedirectPage():
image = pywikibot.FilePage(image.getRedirectTarget())

if not image.exists():
pywikibot.output('[[%s]] doesn\'t exist so I can\'t link to it' % (image.title(),))
pywikibot.output('[[%s]] doesn\'t exist so I can\'t link to it'
% (image.title(),))
return

newclaim.setTarget(image)
pywikibot.output('Adding %s --> %s' % (newclaim.getID(), newclaim.getTarget()))
pywikibot.output('Adding %s --> %s'
% (newclaim.getID(), newclaim.getTarget()))
item.addClaim(newclaim)

# A generator might yield pages from multiple sites
Expand Down
3 changes: 2 additions & 1 deletion scripts/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def main(*args):
options['loose'] = True
elif arg.startswith('-summary'):
if len(arg) == len('-summary'):
options['summary'] = pywikibot.input(u'Choose an edit summary: ')
options['summary'] = pywikibot.input(
'Choose an edit summary: ')
else:
options['summary'] = arg[len('-summary:'):]
elif old_image:
Expand Down

0 comments on commit 6be9916

Please sign in to comment.