jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/474536 )

Change subject: [PEP8] Fix W504 errors in pywikibot/textlib.py
......................................................................

[PEP8] Fix W504 errors in pywikibot/textlib.py

Fixed the W504 error occurrences in the following file:
 - pywikibot/textlib.py

Bug: T207836
Change-Id: Ife2d30f767c314375c539b4a38e099682d2e0dd9
---
M pywikibot/textlib.py
1 file changed, 24 insertions(+), 28 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 6899d8d..83cade7 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -226,10 +226,9 @@
                 '{0!r} is not a valid template'.format(template))

         if namespace.case == 'first-letter':
-            pattern = '[' + \
-                      re.escape(old[0].upper()) + \
-                      re.escape(old[0].lower()) + \
-                      ']' + re.escape(old[1:])
+            pattern = '[{}{}]{}'.format(re.escape(old[0].upper()),
+                                        re.escape(old[0].lower()),
+                                        re.escape(old[1:]))
         else:
             pattern = re.escape(old)
         # namespaces may be any mixed case
@@ -237,9 +236,9 @@
                               for char in ns)
                       for ns in namespace]
         pattern = re.sub(r'_|\\ ', r'[_ ]', pattern)
-        templateRegex = re.compile(r'\{\{ *(' + ':|'.join(namespaces) +
-                                   r':|[mM][sS][gG]:)?' + pattern +
-                                   r'(?P<parameters>\s*\|.+?|) *}}',
+        templateRegex = re.compile(r'\{\{ *(' + ':|'.join(namespaces)
+                                   + r':|[mM][sS][gG]:)?' + pattern
+                                   + r'(?P<parameters>\s*\|.+?|) *}}',
                                    flags)
         return templateRegex

@@ -421,8 +420,8 @@
         for dontTouchR in dontTouchRegexes:
             excMatch = dontTouchR.search(text, index)
             if excMatch and (
-                    nextExceptionMatch is None or
-                    excMatch.start() < nextExceptionMatch.start()):
+                    nextExceptionMatch is None
+                    or excMatch.start() < nextExceptionMatch.start()):
                 nextExceptionMatch = excMatch

         if nextExceptionMatch is not None \
@@ -608,9 +607,9 @@
         striploopcontinue = True
         while firstinseparator > 0 and striploopcontinue:
             striploopcontinue = False
-            if (firstinseparator >= lenseparator) and \
-               (separator == text[firstinseparator -
-                                  lenseparator:firstinseparator]):
+            if (firstinseparator >= lenseparator
+                and separator == text[firstinseparator
+                                      - lenseparator:firstinseparator]):
                 firstinseparator -= lenseparator
                 striploopcontinue = True
             elif text[firstinseparator - 1] < ' ':
@@ -1041,8 +1040,8 @@
         site = pywikibot.Site()
     # This regular expression will find every interwiki link, plus trailing
     # whitespace.
-    languages = '|'.join(site.validLanguageLinks() +
-                         list(site.family.obsolete.keys()))
+    languages = '|'.join(site.validLanguageLinks()
+                         + list(site.family.obsolete.keys()))
     if not languages:
         return text
     interwikiR = re.compile(r'\[\[(%s)\s?:[^\[\]\n]*\]\][\s]*'
@@ -1137,9 +1136,8 @@
             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.code in site.family.categories_last:
                 cats = getCategoryLinks(s2, site=site)
                 s2 = removeCategoryLinksAndSeparator(
@@ -1151,9 +1149,8 @@
             # (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:
@@ -1172,10 +1169,9 @@
                         newtext = regexp.sub(s + includeOff, s2)
                     else:
                         # Put the langlinks at the end, inside noinclude's
-                        newtext = (s2.replace(marker, '').strip() +
-                                   separator +
-                                   '%s\n%s%s\n' % (includeOn, s, includeOff)
-                                   )
+                        newtext = (s2.replace(marker, '').strip()
+                                   + separator
+                                   + '%s\n%s%s\n' % (includeOn, s, includeOff))
                 else:
                     newtext = s2.replace(marker, '').strip() + separator + s
     else:
@@ -1642,8 +1638,8 @@
     @return: list of template name and params
     @rtype: list of tuple
     """
-    use_mwparserfromhell = (config.use_mwparserfromhell and
-                            not isinstance(mwparserfromhell, Exception))
+    use_mwparserfromhell = (config.use_mwparserfromhell
+                            and not isinstance(mwparserfromhell, Exception))

     if remove_disabled_parts is None:
         remove_disabled_parts = not use_mwparserfromhell
@@ -2315,8 +2311,8 @@

         # all fields matched -> date valid
         # groups are in a reasonable order.
-        if (all(g in dateDict for g in self.groups) and
-                self._valid_date_dict_positions(dateDict)):
+        if (all(g in dateDict for g in self.groups)
+                and self._valid_date_dict_positions(dateDict)):
             # remove 'time' key, now split in hour/minute and not needed
             # by datetime.
             del dateDict['time']

--
To view, visit https://gerrit.wikimedia.org/r/474536
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ife2d30f767c314375c539b4a38e099682d2e0dd9
Gerrit-Change-Number: 474536
Gerrit-PatchSet: 3
Gerrit-Owner: Nathan fraignt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Dvorapa <[email protected]>
Gerrit-Reviewer: Framawiki <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Nathan fraignt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot (75)
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to