jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/616218 )
Change subject: [4.0] remove deprecated re.UNICODE from several scripts ......................................................................
[4.0] remove deprecated re.UNICODE from several scripts
Change-Id: I7d06a28ce12e3e97de710731f7ba6678d2eab642 --- M pywikibot/cosmetic_changes.py M scripts/checkimages.py M scripts/noreferences.py M scripts/revertbot.py 4 files changed, 21 insertions(+), 26 deletions(-)
Approvals: Matěj Suchánek: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index 740d5a1..3d85630 100755 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -56,25 +56,23 @@ # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, division, unicode_literals - import re
-try: - import stdnum.isbn as stdnum_isbn -except ImportError: - stdnum_isbn = None - import pywikibot
from pywikibot.page import url2unicode from pywikibot import textlib -from pywikibot.textlib import (_MultiTemplateMatchBuilder, FILE_LINK_REGEX, - _get_regexes) +from pywikibot.textlib import ( + _get_regexes, _MultiTemplateMatchBuilder, FILE_LINK_REGEX +) from pywikibot.tools import ( deprecated, deprecated_args, first_lower, first_upper )
+try: + import stdnum.isbn as stdnum_isbn +except ImportError: + stdnum_isbn = None
# Subpage templates. Must be in lower case, # whereas subpage itself must be case sensitive @@ -200,7 +198,7 @@ text, lambda match: _format_isbn_match(match, strict=strict))
-class CosmeticChangesToolkit(object): +class CosmeticChangesToolkit:
"""Cosmetic changes toolkit."""
@@ -932,7 +930,7 @@ site=self.site) # Solve wrong Nº sign with °C or °F # additional exception requested on fr-wiki for this stuff - pattern = re.compile('«.*?»', re.UNICODE) + pattern = re.compile('«.*?»') exceptions.append(pattern) text = textlib.replaceExcept(text, r'(\d)\s*(?: )?[º°]([CF])', r'\1 °\2', exceptions, diff --git a/scripts/checkimages.py b/scripts/checkimages.py index 96f2d50..dc3d749 100755 --- a/scripts/checkimages.py +++ b/scripts/checkimages.py @@ -454,7 +454,7 @@ *[Hh]ead\ ?=\ ?['"](.*?)['"]\n *[Tt]ext\ ?=\ ?['"](.*?)['"]\n *[Mm]ex\ ?=\ ?['"]?([^\n]*?)['"]?\n -""", re.UNICODE | re.DOTALL | re.VERBOSE) +""", re.DOTALL | re.VERBOSE)
class LogIsFull(pywikibot.Error): @@ -714,7 +714,7 @@ def regexGenerator(self, regexp, textrun) -> Generator[pywikibot.FilePage, None, None]: """Find page to yield using regex to parse text.""" - regex = re.compile(r'{}'.format(regexp), re.UNICODE | re.DOTALL) + regex = re.compile(r'{}'.format(regexp), re.DOTALL) results = regex.findall(textrun) for image in results: yield pywikibot.FilePage(self.site, image) @@ -1263,7 +1263,7 @@ # I search with a regex how many user have not the talk page # and i put them in a list (i find it more easy and secure) regl = r"("|')(.*?)\1(?:,|])" - pl = re.compile(regl, re.UNICODE) + pl = re.compile(regl) for xl in pl.finditer(raw): word = xl.group(2).replace('\\', '\') if word not in list_loaded: diff --git a/scripts/noreferences.py b/scripts/noreferences.py index 9e5a160..8e93134 100755 --- a/scripts/noreferences.py +++ b/scripts/noreferences.py @@ -527,23 +527,23 @@ if self.getOption('verbose'): pywikibot.output('No changes necessary: references tag found.') return False - elif self.referencesTemplates: + + if self.referencesTemplates: templateR = '{{(' + '|'.join(self.referencesTemplates) + ')' - if re.search( - templateR, oldTextCleaned, re.IGNORECASE | re.UNICODE - ): + if re.search(templateR, oldTextCleaned, re.IGNORECASE): if self.getOption('verbose'): pywikibot.output( 'No changes necessary: references template found.') return False + if not self.refR.search(oldTextCleaned): if self.getOption('verbose'): pywikibot.output('No changes necessary: no ref tags found.') return False - else: - if self.getOption('verbose'): - pywikibot.output('Found ref without references.') - return True + + if self.getOption('verbose'): + pywikibot.output('Found ref without references.') + return True
def addReferences(self, oldText) -> str: """ diff --git a/scripts/revertbot.py b/scripts/revertbot.py index 8d3a428..7c3446d 100755 --- a/scripts/revertbot.py +++ b/scripts/revertbot.py @@ -31,7 +31,7 @@ if 'top' in item: page = pywikibot.Page(self.site, item['title']) text = page.get(get_redirect=True) - pattern = re.compile(r'[[.+?:.+?..+?]]', re.UNICODE) + pattern = re.compile(r'[[.+?:.+?..+?]]') return bool(pattern.search(text)) return False
@@ -39,9 +39,6 @@ # # (C) Pywikibot team, 2008-2020 # -# Ported by Geoffrey "GEOFBOT" Mon - User:Sn1per -# for Google Code-In 2013 -# # Distributed under the terms of the MIT license. # from typing import Union
pywikibot-commits@lists.wikimedia.org