Ladsgroup has uploaded a new change for review.
https://gerrit.wikimedia.org/r/185647
Change subject: Split too long lines part II
......................................................................
Split too long lines part II
The maximum is 170 characters now
Alongside with some other minor pep8 fixes
Change-Id: I28c15577df3857a04d820ccd2f5558d92450f424
---
M pywikibot/families/wikibooks_family.py
M pywikibot/families/wiktionary_family.py
M pywikibot/fixes.py
M scripts/checkimages.py
M scripts/commonscat.py
M scripts/data_ingestion.py
M scripts/image.py
M scripts/interwiki.py
M scripts/script_wui.py
M scripts/states_redirect.py
M scripts/weblinkchecker.py
M tests/i18n/test.py
M tests/pagegenerators_tests.py
M tests/ui_tests.py
M tox.ini
15 files changed, 117 insertions(+), 58 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/47/185647/1
diff --git a/pywikibot/families/wikibooks_family.py
b/pywikibot/families/wikibooks_family.py
index 6cbc6ab..eccb20f 100644
--- a/pywikibot/families/wikibooks_family.py
+++ b/pywikibot/families/wikibooks_family.py
@@ -54,7 +54,7 @@
self.obsolete = {
'aa': None, #
https://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Afar_Wikibooks
'ak': None, #
https://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Akan_Wikibooks
- 'als': None, #
https://als.wikipedia.org/wiki/Wikipedia:Stammtisch/Archiv_2008-1#Afterwards.2C_closure_and_deletion_of_Wiktionary.2C_Wikibooks_and_Wikiquote_sites
+ 'als': None, #
https://als.wikipedia.org/wiki/Special:PermaLink/603754#Closing_wt.2C_wb.2C_wq
'as': None, #
https://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Assamese_Wikibooks
'ast': None,
'ay': None, #
https://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Aymar_Wikibooks
diff --git a/pywikibot/families/wiktionary_family.py
b/pywikibot/families/wiktionary_family.py
index bb2504f..374dc0a 100644
--- a/pywikibot/families/wiktionary_family.py
+++ b/pywikibot/families/wiktionary_family.py
@@ -97,7 +97,7 @@
'aa': None, #
https://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Afar_Wiktionary
'ab': None, #
https://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Abkhaz_Wiktionary
'ak': None, #
https://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Akan_Wiktionary
- 'als': None, #
https://als.wikipedia.org/wiki/Wikipedia:Stammtisch/Archiv_2008-1#Afterwards.2C_closure_and_deletion_of_Wiktionary.2C_Wikibooks_and_Wikiquote_sites
+ 'als': None, #
https://als.wikipedia.org/wiki/Special:PermaLink/603754#Closing_wt.2C_wb.2C_wq
'as': None, #
https://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Assamese_Wiktionary
'av': None, #
https://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Avar_Wiktionary
'ba': None, #
https://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Bashkir_Wiktionary
diff --git a/pywikibot/fixes.py b/pywikibot/fixes.py
index e2e3e4e..a045db3 100644
--- a/pywikibot/fixes.py
+++ b/pywikibot/fixes.py
@@ -129,14 +129,14 @@
# Temperaturangabe mit falsch gesetztem Leerzeichen
(u'(?<!\w)(\d+|\d+[\.,]\d+)° C(?=\W|²|³|$)', r'\1' + u' °C'),
# Kein Leerzeichen nach Komma
- (u'([a-zäöüß](\]\])?,)((\[\[)?[a-zäöüA-ZÄÖÜ])',
r'\1 \3'),
+ (u'([a-zäöüß](\]\])?,)((\[\[)?[a-zäöüA-ZÄÖÜ])', r'\1 \3'),
# Leerzeichen und Komma vertauscht
- (u'([a-zäöüß](\]\])?) ,((\[\[)?[a-zäöüA-ZÄÖÜ])',
r'\1, \3'),
+ (u'([a-zäöüß](\]\])?) ,((\[\[)?[a-zäöüA-ZÄÖÜ])', r'\1, \3'),
# Plenks (d. h. Leerzeichen auch vor dem
Komma/Punkt/Ausrufezeichen/Fragezeichen)
# Achtung bei Französisch:
https://de.wikipedia.org/wiki/Plenk#Sonderfall_Franz.C3.B6sisch
# Leerzeichen vor Doppelpunkt/Semikolon kann korrekt sein, nach
irgendeiner Norm für Zitationen.
- (u'([a-zäöüß](\]\])?) ([,\.!\?]) ((\[\[)?[a-zäöüA-ZÄÖÜ])',
r'\1\3 \4'),
- # (u'([a-z]\.)([A-Z])',
r'\1 \2'),
+ (u'([a-zäöüß](\]\])?) ([,\.!\?]) ((\[\[)?[a-zäöüA-ZÄÖÜ])', r'\1\3
\4'),
+ # (u'([a-z]\.)([A-Z])', r'\1 \2'),
],
'exceptions': {
'inside-tags': [
@@ -172,9 +172,11 @@
r'(?m)^;(.*?)$', # Definitionslisten, dort gibt es oft
absichtlich Leerzeichen vor Doppelpunkten
r'\d+h( | )\d+m', # Schreibweise für Zeiten, vor allem
in Film-Infoboxen. Nicht korrekt, aber dafür schön kurz.
r'(?i)\[\[(Bild|Image|Media):.+?\|', # Dateinamen auslassen
- r'{{bgc\|.*?}}', # Hintergrundfarbe
+ r'{{bgc\|.*?}}', # Hintergrundfarbe
r'<sup>\d+m</sup>', # bei chemischen Formeln
-
r'\([A-Z][A-Za-z]*(,[A-Z][A-Za-z]*(<sup>.*?</sup>|<sub>.*?</sub>|))+\)' #
chemische Formel, z. B. AuPb(Pb,Sb,Bi)Te. Hier sollen keine Leerzeichen hinter
die Kommata.
+
r'\([A-Z][A-Za-z]*(,[A-Z][A-Za-z]*(<sup>.*?</sup>|<sub>.*?</sub>|))+\)'
+ # chemische Formel, z. B. AuPb(Pb,Sb,Bi)Te.
+ # Hier sollen keine Leerzeichen hinter die Kommata.
],
'title': [
r'Arsen', # chemische Formel
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 11cdf22..315c606 100644
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -302,7 +302,9 @@
'en': u"{{subst:image source|File:%s}} --~~~~",
'fa': u"{{جا:اخطار نگاره|%s}}",
'ga': u"{{subst:Foinse na híomhá|File:%s}} --~~~~",
- 'hu': u"{{subst:adjforrást|Kép:%s}} \n Ezt az üzenetet ~~~ automatikusan
helyezte el a vitalapodon, kérdéseddel fordulj a gazdájához, vagy a
[[WP:KF|Kocsmafalhoz]]. --~~~~",
+ 'hu': u"{{subst:adjforrást|Kép:%s}} \n Ezt az üzenetet ~~~ automatikusan "
+ u"helyezte el a vitalapodon, kérdéseddel fordulj a gazdájához, vagy "
+ u"a [[WP:KF|Kocsmafalhoz]]. --~~~~",
'it': u"{{subst:Progetto:Coordinamento/Immagini/Bot/Messaggi/Senza
licenza|%s|__botnick__}} --~~~~",
'ja': u"\n{{subst:Image copyright|File:%s}}--~~~~",
'ko': u'\n{{subst:User:Kwjbot IV/untagged|%s}} --~~~~',
diff --git a/scripts/commonscat.py b/scripts/commonscat.py
index d276360..ae607e1 100755
--- a/scripts/commonscat.py
+++ b/scripts/commonscat.py
@@ -221,20 +221,34 @@
}
msg_change = {
- 'be-x-old': u'Робат: зьмяніў шаблён
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] на
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'cs': u'Robot změnil šablonu Commonscat z
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] na
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'da': u'Robot: Ændrer commonscat link fra
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] til
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'de': u'Bot: Ändere commonscat link von
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] zu
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'en': u'Bot: Changing commonscat link from
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] to
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'fa': u'ربات: تغییر پیوند به انبار از
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] به
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'fr': u'Robot: Changé commonscat link de
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] à
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'frr': u'Bot: Feranere commonscat link faan
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] tu
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'is': u'Vélmenni: Breyti Commonscat tengli frá
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] í
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'pdc': u'Waddefresser: commonscat Gleecher vun
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] nooch
[[:Commons:Category:%(newcat)s|%(newcat)s]] geennert',
- 'ru': u'Бот: Изменение commonscat-ссылки с
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] на
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'sk': u'Robot zmenil šablónu Commonscat z
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] na
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'uk': u'Бот: Зміна commonscat-посилання з
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] на
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
- 'th': u'บอต: เปลี่ยนลิงก์หมวดหมู่คอมมอนส์จาก
[[:Commons:Category:%(oldcat)s|%(oldcat)s]] เป็น
[[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'be-x-old': u'Робат: зьмяніў шаблён
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' на [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'cs': u'Robot změnil šablonu Commonscat z
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' na [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'da': u'Robot: Ændrer commonscat link fra
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' til [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'de': u'Bot: Ändere commonscat link von
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' zu [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'en': u'Bot: Changing commonscat link from
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' to [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'fa': u'ربات: تغییر پیوند به انبار از
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' به [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'fr': u'Robot: Changé commonscat link de
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' à [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'frr': u'Bot: Feranere commonscat link faan
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' tu [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'is': u'Vélmenni: Breyti Commonscat tengli frá
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' í [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'pdc': u'Waddefresser: commonscat Gleecher vun
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' nooch [[:Commons:Category:%(newcat)s|%(newcat)s]] geennert',
+ 'ru': u'Бот: Изменение commonscat-ссылки с
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' на [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'sk': u'Robot zmenil šablónu Commonscat z
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' na [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'uk': u'Бот: Зміна commonscat-посилання з
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' на [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'th': u'บอต: เปลี่ยนลิงก์หมวดหมู่คอมมอนส์จาก
[[:Commons:Category:%(oldcat)s|%(oldcat)s]]'
+ u' เป็น [[:Commons:Category:%(newcat)s|%(newcat)s]]',
'zh': u'機器人:更改 commonscat 連結,從 %(oldcat)s 至 %(newcat)s',
}
diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py
index 72e22f5..2c5c2bd 100755
--- a/scripts/data_ingestion.py
+++ b/scripts/data_ingestion.py
@@ -177,11 +177,11 @@
"""
Expects a pywikibot.page object "configurationPage" which contains the
configuration
"""
- configuration = {}
+ configuration = {}
# Set a bunch of defaults
- configuration['csvDialect']=u'excel'
- configuration['csvDelimiter']=';'
- configuration['csvEncoding']=u'Windows-1252' #FIXME: Encoding hell
+ configuration['csvDialect'] = u'excel'
+ configuration['csvDelimiter'] = ';'
+ configuration['csvEncoding'] = u'Windows-1252' # FIXME: Encoding hell
templates = configurationPage.templatesWithParams()
for (template, params) in templates:
@@ -195,7 +195,6 @@
configuration[field] = value
print(configuration)
return configuration
-
def downloadPhoto(self, photoUrl=''):
"""
@@ -230,7 +229,7 @@
identifier = metadata.get(u'dc:identifier')
if len(description) > 120:
- description = description[0 : 120]
+ description = description[0:120]
title = u'%s - %s.jpg' % (description, identifier)
@@ -271,17 +270,21 @@
title = self.getTitle(metadata)
description = self.getDescription(metadata)
-
pywikibot.output(u'Preparing upload for %s.' % title)
pywikibot.output(description)
- bot = upload.UploadRobot(url=fileLocation, description=description,
useFilename=title, keepFilename=True, verifyDescription=False, targetSite =
self.site)
+ bot = upload.UploadRobot(
+ url=fileLocation, description=description, useFilename=title,
+ keepFilename=True, verifyDescription=False, targetSite=self.site)
bot.run()
def processCSV(self):
database = {}
- reader = csv.DictReader(open(self.configuration.get('csvFile'), "rb"),
dialect=self.configuration.get('csvDialect'),
delimiter=self.configuration.csvDelimiter)
+ reader = csv.DictReader(
+ open(self.configuration.get('csvFile'), "rb"),
+ dialect=self.configuration.get('csvDialect'),
+ delimiter=self.configuration.csvDelimiter)
# FIXME : Encoding problems
https://docs.python.org/2/library/csv.html#csv-examples
for row in reader:
self.metadataCSV(row)
@@ -300,8 +303,9 @@
else:
pywikibot.output(u'%s is not a supported source format')
+
def main():
- generator = None;
+ generator = None
# Process global args and prepare generator args parser
local_args = pywikibot.handleArgs()
@@ -315,7 +319,7 @@
return False
for page in generator:
- bot = DataIngestionBot(page)
+ bot = DataIngestionBot(page)
bot.run()
if __name__ == "__main__":
diff --git a/scripts/image.py b/scripts/image.py
index 009478d..00758e4 100644
--- a/scripts/image.py
+++ b/scripts/image.py
@@ -147,7 +147,9 @@
# Be careful, spaces and _ have been converted to '\ ' and '\_'
escaped = re.sub('\\\\[_ ]', '[_ ]', escaped)
if not self.getOption('loose') or not self.new_image:
- image_regex = re.compile(r'\[\[ *(?:' +
'|'.join(self.site.namespace(6, all=True)) + ')\s*:\s*' + escaped + '
*(?P<parameters>\|[^\n]+|) *\]\]')
+ image_regex = re.compile(
+ r'\[\[ *(?:%s)\s*:\s*%s *(?P<parameters>\|[^\n]+|) *\]\]'
+ % ('|'.join(self.site.namespace(6, all=True)), escaped))
else:
image_regex = re.compile(r'' + escaped)
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 1158110..93cb2f8 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -2587,7 +2587,10 @@
pywikibot.output(u"Dump file is empty?! Starting at the
beginning.")
nextPage = "!"
namespace = 0
- hintlessPageGen =
pagegenerators.CombinedPageGenerator([hintlessPageGen,
pagegenerators.AllpagesPageGenerator(nextPage, namespace,
includeredirects=False)])
+ gen2 = pagegenerators.AllpagesPageGenerator(
+ nextPage, namespace, includeredirects=False)
+ hintlessPageGen = pagegenerators.CombinedPageGenerator(
+ [hintlessPageGen, gen2])
site.login()
bot = InterwikiBot()
diff --git a/scripts/script_wui.py b/scripts/script_wui.py
index 12dea61..f286e7a 100755
--- a/scripts/script_wui.py
+++ b/scripts/script_wui.py
@@ -262,7 +262,11 @@
pywikibot.config.simulate = __simulate
sys.argv = __sys_argv
- pywikibot.output(u'environment: garbage; %s / memory; %s / members; %s' %
(gc.collect(), resource.getrusage(resource.RUSAGE_SELF).ru_maxrss *
resource.getpagesize(), len(dir())))
+ pywikibot.output(
+ u'environment: garbage; %s / memory; %s / members; %s' % (
+ gc.collect(),
+ resource.getrusage(resource.RUSAGE_SELF).ru_maxrss *
resource.getpagesize(),
+ len(dir())))
# 'len(dir())' is equivalent to 'len(inspect.getmembers(__main__))'
# append result to output page
@@ -283,7 +287,9 @@
# append to page
outpage = pywikibot.Page(pywikibot.Site(), bot_config['ConfCSSoutput'])
text = outpage.get()
- outpage.put(text + u"\n== Simulation vom %s mit [%s code:%s]
==\n<pre>\n%s</pre>\n\n" % (pywikibot.Timestamp.now().isoformat(' '), link,
rev, buffer))
+ outpage.put(
+ text + u"\n== Simulation vom %s mit [%s code:%s]
==\n<pre>\n%s</pre>\n\n" % (
+ pywikibot.Timestamp.now().isoformat(' '), link, rev, buffer))
# comment = pywikibot.translate(self.site.lang,
bot_config['msg']))
diff --git a/scripts/states_redirect.py b/scripts/states_redirect.py
index 2ec6898..b064e4f 100644
--- a/scripts/states_redirect.py
+++ b/scripts/states_redirect.py
@@ -112,10 +112,9 @@
if self.force:
change = 'y'
else:
- change = pywikibot.input_choice(u'Create redirect\
- %s?' % pl.title(),
- (('yes', 'y'),
- ('no', 'n')))
+ change = pywikibot.input_choice(
+ u'Create redirect\%s?' % pl.title(),
+ (('yes', 'y'), ('no', 'n')))
if change == 'y':
pl.text = '#REDIRECT [[%s]]' % p2.title()
pl.save(i18n.translate(self.site, msg))
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index 4bc522f..3e8aff9 100644
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -139,7 +139,8 @@
# Other special cases
re.compile('.*[\./@]gso\.gbv\.de(/.*)?'), # bot somehow can't handle
their redirects
- re.compile('.*[\./@]berlinonline\.de(/.*)?'), # a de: user wants to fix
them by hand and doesn't want them to be deleted, see
[[de:Benutzer:BLueFiSH.as/BZ]].
+ re.compile('.*[\./@]berlinonline\.de(/.*)?'),
+ # a de: user wants to fix them by hand and doesn't want them to be
deleted, see [[de:Benutzer:BLueFiSH.as/BZ]].
re.compile('.*[\./@]bodo\.kommune\.no(/.*)?'), # bot can't handle their
redirects
re.compile('.*[\./@]jpl\.nasa\.gov(/.*)?'), # bot rejected on the site
re.compile('.*[\./@]itis\.gov(/.*)?'), # bot rejected on the site
diff --git a/tests/i18n/test.py b/tests/i18n/test.py
index b2585f7..24c15d9 100644
--- a/tests/i18n/test.py
+++ b/tests/i18n/test.py
@@ -3,7 +3,9 @@
msg = {
'de': {
'test-plural': u'Bot: Ändere %(num)d {{PLURAL:num|Seite|Seiten}}.',
- 'test-multiple-plurals': u'Bot: %(action)s %(line)s
{{PLURAL:line|Zeile|Zeilen}} von {{PLURAL:%(page)d|einer|mehreren}}
{{PLURAL:page|Seite|Seiten}}.',
+ 'test-multiple-plurals': u'Bot: %(action)s %(line)s {{PLURAL:line|'
+ u'Zeile|Zeilen}} von {{PLURAL:%(page)d|einer|'
+ u'mehreren}} {{PLURAL:page|Seite|Seiten}}.',
},
'en': {
'test-localized': u'test-localized EN',
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index ae7e2d8..d723954 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -743,9 +743,9 @@
site = self.get_site()
self.assertEqualItertools(
[pagegenerators.NewpagesPageGenerator(site=site, total=10),
- pagegenerators.CategorizedPageGenerator(
- pywikibot.Category(site,
- 'Category:Candidates_for_speedy_deletion'))
+ pagegenerators.CategorizedPageGenerator(
+ pywikibot.Category(
+ site, 'Category:Candidates_for_speedy_deletion'))
])
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index f792efc..795f2bd 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -319,27 +319,43 @@
"""Terminal output color tests."""
def testOutputColorizedText(self):
- pywikibot.output(u"normal text \03{lightpurple}light purple
text\03{default} normal text")
+ pywikibot.output(
+ u"normal text \03{lightpurple}light purple text\03{default}
normal text")
self.assertEqual(newstdout.getvalue(), "")
- self.assertEqual(newstderr.getvalue(), "normal text
\x1b[35;1mlight purple text\x1b[0m normal text\n\x1b[0m")
+ self.assertEqual(
+ newstderr.getvalue(),
+ "normal text \x1b[35;1mlight purple text\x1b[0m normal
text\n\x1b[0m")
def testOutputNoncolorizedText(self):
pywikibot.config.colorized_output = False
- pywikibot.output(u"normal text \03{lightpurple}light purple
text\03{default} normal text")
+ pywikibot.output(
+ u"normal text \03{lightpurple}light purple text\03{default}
normal text")
self.assertEqual(newstdout.getvalue(), "")
- self.assertEqual(newstderr.getvalue(), "normal text light purple
text normal text ***\n")
+ self.assertEqual(
+ newstderr.getvalue(),
+ "normal text light purple text normal text ***\n")
@unittest.expectedFailure
def testOutputColorCascade(self):
- pywikibot.output(u"normal text \03{lightpurple} light purple
\03{lightblue} light blue \03{default} light purple \03{default} normal text")
+ pywikibot.output(
+ u"normal text \03{lightpurple} light purple \03{lightblue} "
+ u"light blue \03{default} light purple \03{default} normal
text")
self.assertEqual(newstdout.getvalue(), "")
- self.assertEqual(newstderr.getvalue(), "normal text \x1b[35;1m
light purple \x1b[94;1m light blue \x1b[35;1m light purple \x1b[0m normal
text\n\x1b[0m")
+ self.assertEqual(
+ newstderr.getvalue(),
+ "normal text \x1b[35;1m light purple \x1b[94;1m light blue "
+ "\x1b[35;1m light purple \x1b[0m normal text\n\x1b[0m")
def testOutputColorCascade_incorrect(self):
""" Test incorrect behavior of testOutputColorCascade. """
- pywikibot.output(u"normal text \03{lightpurple} light purple
\03{lightblue} light blue \03{default} light purple \03{default} normal text")
+ pywikibot.output(
+ u"normal text \03{lightpurple} light purple \03{lightblue} "
+ u"light blue \03{default} light purple \03{default} normal
text")
self.assertEqual(newstdout.getvalue(), "")
- self.assertEqual(newstderr.getvalue(), "normal text \x1b[35;1m
light purple \x1b[94;1m light blue \x1b[0m light purple \x1b[0m normal
text\n\x1b[0m")
+ self.assertEqual(
+ newstderr.getvalue(),
+ "normal text \x1b[35;1m light purple \x1b[94;1m light blue "
+ "\x1b[0m light purple \x1b[0m normal text\n\x1b[0m")
@unittest.skipUnless(os.name == "posix", "requires Unix console")
class TestTerminalUnicodeUnix(UITestCase):
@@ -373,7 +389,12 @@
pywikibot.config.transliterate = True
pywikibot.output(u"abcd АБГД αβγδ あいうえお")
self.assertEqual(newstdout.getvalue(), "")
- self.assertEqual(newstderr.getvalue(), "abcd
\x1b[33;1mA\x1b[0m\x1b[33;1mB\x1b[0m\x1b[33;1mG\x1b[0m\x1b[33;1mD\x1b[0m
\x1b[33;1ma\x1b[0m\x1b[33;1mb\x1b[0m\x1b[33;1mg\x1b[0m\x1b[33;1md\x1b[0m
\x1b[33;1ma\x1b[0m\x1b[33;1mi\x1b[0m\x1b[33;1mu\x1b[0m\x1b[33;1me\x1b[0m\x1b[33;1mo\x1b[0m\n\x1b[0m")
# noqa
+ self.assertEqual(
+ newstderr.getvalue(),
+ "abcd
\x1b[33;1mA\x1b[0m\x1b[33;1mB\x1b[0m\x1b[33;1mG\x1b[0m\x1b[33;1mD\x1b[0m "
+
"\x1b[33;1ma\x1b[0m\x1b[33;1mb\x1b[0m\x1b[33;1mg\x1b[0m\x1b[33;1md\x1b[0m "
+
"\x1b[33;1ma\x1b[0m\x1b[33;1mi\x1b[0m\x1b[33;1mu\x1b[0m\x1b[33;1me\x1b[0m"
+ "\x1b[33;1mo\x1b[0m\n\x1b[0m") # noqa
@unittest.skipUnless(os.name == "nt", "requires Windows console")
class WindowsTerminalTestCase(UITestCase):
@@ -506,7 +527,10 @@
pass
def testOutputUnicodeText_no_transliterate(self):
- self.sendstdin(u"""python -c "import os, pywikibot;
os.system('cls'); pywikibot.output(u'\\n'.join(pywikibot.handleArgs()))" Alpha
Bετα Гамма دلتا\n""")
+ self.sendstdin(
+ u"python -c \"import os, pywikibot; os.system('cls'); "
+ u"pywikibot.output(u'\\n'.join(pywikibot.handleArgs()))\" "
+ u"Alpha Bετα Гамма دلتا\n")
while(True):
lines = self.getstdouterr().split("\n")
if len(lines) >= 4 and lines[0] == "Alpha":
diff --git a/tox.ini b/tox.ini
index ae60d99..78ccfaf 100644
--- a/tox.ini
+++ b/tox.ini
@@ -138,5 +138,5 @@
[pep8]
ignore = E122,E127,E241
exclude =
.tox,.git,./*.egg,ez_setup.py,build,externals,user-config.py,./scripts/i18n/*,./pywikibot/date.py
-max_line_length = 200
+max_line_length = 150
--
To view, visit https://gerrit.wikimedia.org/r/185647
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I28c15577df3857a04d820ccd2f5558d92450f424
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits