jenkins-bot has submitted this change and it was merged.
Change subject: pep8-ified textlib.py ......................................................................
pep8-ified textlib.py
Change-Id: Ib1a3ad3985ca231c5a60e34cd974bba4cb932e1d --- M pywikibot/textlib.py 1 file changed, 24 insertions(+), 19 deletions(-)
Approvals: Ladsgroup: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index df5926d..c30b678 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -25,6 +25,7 @@ TEMP_REGEX = re.compile( '{{(?:msg:)?(?P<name>[^{|]+?)(?:|(?P<params>[^{]+?(?:{[^{]+?}[^{]*?)?))?}}')
+ def unescape(s): """Replace escaped HTML-special characters by their originals""" if '&' not in s: @@ -218,12 +219,12 @@ groupMatch = groupR.search(replacement) if not groupMatch: break - groupID = groupMatch.group('name') or \ - int(groupMatch.group('number')) + groupID = (groupMatch.group('name') or \ + int(groupMatch.group('number'))) try: - replacement = replacement[:groupMatch.start()] + \ - match.group(groupID) + \ - replacement[groupMatch.end():] + replacement = (replacement[:groupMatch.start()] + \ + match.group(groupID) + \ + replacement[groupMatch.end():]) except IndexError: print '\nInvalid group reference:', groupID print 'Groups found:\n', match.groups() @@ -355,7 +356,7 @@ lenseparator:firstinseparator]): firstinseparator -= lenseparator striploopcontinue = True - elif text[firstinseparator-1] < ' ': + elif text[firstinseparator - 1] < ' ': firstinseparator -= 1 striploopcontinue = True marker = text[firstinseparator:firstinmarker] + marker @@ -512,10 +513,9 @@ if site.language() in site.family.interwiki_attop or \ u'<!-- interwiki at top -->' in oldtext: #do not add separator if interiki links are on one line - newtext = s + \ - [separator, u''][site.language() in - site.family.interwiki_on_one_line] + \ - s2.replace(marker, '').strip() + newtext = (s + + [u'' if site.language() else separator] + \ + s2.replace(marker, '').strip()) else: # calculate what was after the language links on the page firstafter = s2.find(marker) @@ -527,8 +527,9 @@ if "</noinclude>" in s2[firstafter:]: if separatorstripped: s = separator + s - newtext = s2[:firstafter].replace(marker, '') + s + \ - s2[firstafter:] + newtext = (s2[:firstafter].replace(marker, '') + + s + + s2[firstafter:]) elif site.language() in site.family.categories_last: cats = getCategoryLinks(s2, site=site) s2 = removeCategoryLinksAndSeparator( @@ -540,8 +541,9 @@ # (not supported by rewrite - no API) elif site.family.name == 'wikitravel': s = separator + s + separator - newtext = s2[:firstafter].replace(marker, '') + s + \ - s2[firstafter:] + newtext = (s2[:firstafter].replace(marker, '') + + s + + s2[firstafter:]) else: if template or template_subpage: if template_subpage: @@ -560,8 +562,10 @@ newtext = regexp.sub(s + includeOff, s2) else: # Put the langlinks at the end, inside noinclude's - newtext = s2.replace(marker, '').strip() + separator + \ - u'%s\n%s%s\n' % (includeOn, s, includeOff) + newtext = (s2.replace(marker, '').strip() + + separator + + u'%s\n%s%s\n' % (includeOn, s, includeOff) + ) else: newtext = s2.replace(marker, '').strip() + separator + s else: @@ -792,8 +796,9 @@ if "</noinclude>" in s2[firstafter:]: if separatorstripped: s = separator + s - newtext = s2[:firstafter].replace(marker, '') + s + \ - s2[firstafter:] + newtext = (s2[:firstafter].replace(marker, '') + + s + + s2[firstafter:]) elif site.language() in site.family.categories_last: newtext = s2.replace(marker, '').strip() + separator + s else: @@ -827,7 +832,7 @@ if categories[0][0] == '[': catLinks = categories else: - catLinks = ['[[Category:'+category+']]' for category in categories] + catLinks = ['[[Category:' + category + ']]' for category in categories] else: catLinks = [category.aslink(noInterwiki=True) for category in categories]
pywikibot-commits@lists.wikimedia.org