jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/627851 )
Change subject: [cleanup] Remove desupported textlib methods ......................................................................
[cleanup] Remove desupported textlib methods
textlib methods should be imported from textlib instead of pywikibot. Using the methods pywikibot are deprecated for 6 years.
Change-Id: I8f976961f0c562fc9a00192bf324022383af68f3 --- M pywikibot/__init__.py M scripts/imagecopy_self.py 2 files changed, 6 insertions(+), 25 deletions(-)
Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index 7045a95..98c543c 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -55,7 +55,6 @@ critical, debug, error, exception, log, output, stdout, warning ) from pywikibot.site import BaseSite -import pywikibot.textlib as textlib from pywikibot.tools import ( # __ to avoid conflict with ModuleDeprecationWrapper._deprecated classproperty, @@ -77,16 +76,6 @@ cache = lru_cache(None)
-textlib_methods = ( - 'categoryFormat', 'compileLinkR', 'extract_templates_and_params', - 'getCategoryLinks', 'getLanguageLinks', 'interwikiFormat', 'interwikiSort', - 'isDisabled', 'removeCategoryLinks', 'removeCategoryLinksAndSeparator', - 'removeDisabledParts', 'removeHTMLParts', 'removeLanguageLinks', - 'removeLanguageLinksAndSeparator', 'replaceCategoryInPlace', - 'replaceCategoryLinks', 'replaceExcept', 'replaceLanguageLinks', - 'TimeStripper', 'unescape', -) - __all__ = ( '__copyright__', '__description__', '__download_url__', '__license__', '__maintainer__', '__maintainer_email__', '__name__', '__release__', @@ -110,13 +99,6 @@ 'UserBlocked', 'warning', 'WbGeoShape', 'WbMonolingualText', 'WbQuantity', 'WbTabularData', 'WbTime', 'WbUnknown', 'WikiBaseError', 'WikidataBot', ) -__all__ += textlib_methods - - -for _name in textlib_methods: - target = getattr(textlib, _name) - wrapped_func = redirect_func(target, since='20140820', future_warning=True) - globals()[_name] = wrapped_func
class Timestamp(datetime.datetime): @@ -211,23 +193,21 @@
def __add__(self, other): """Perform addition, returning a Timestamp instead of datetime.""" - newdt = super(Timestamp, self).__add__(other) + newdt = super().__add__(other) if isinstance(newdt, datetime.datetime): return Timestamp(newdt.year, newdt.month, newdt.day, newdt.hour, newdt.minute, newdt.second, newdt.microsecond, newdt.tzinfo) - else: - return newdt + return newdt
def __sub__(self, other): """Perform subtraction, returning a Timestamp instead of datetime.""" - newdt = super(Timestamp, self).__sub__(other) + newdt = super().__sub__(other) if isinstance(newdt, datetime.datetime): return Timestamp(newdt.year, newdt.month, newdt.day, newdt.hour, newdt.minute, newdt.second, newdt.microsecond, newdt.tzinfo) - else: - return newdt + return newdt
class Coordinate(_WbRepresentation): diff --git a/scripts/imagecopy_self.py b/scripts/imagecopy_self.py index ee55da5..8580388 100644 --- a/scripts/imagecopy_self.py +++ b/scripts/imagecopy_self.py @@ -50,6 +50,7 @@ from pywikibot import pagegenerators, i18n
from pywikibot.specialbots import UploadRobot +from pywikibot.textlib import removeCategoryLinks from pywikibot.tools import PY2
from scripts import imagerecat, image @@ -504,7 +505,7 @@ for (regex, repl) in licenseTemplates[imagepage.site.lang]: text = re.sub(regex, '', text, flags=re.IGNORECASE)
- text = pywikibot.removeCategoryLinks(text, imagepage.site()) + text = removeCategoryLinks(text, imagepage.site())
description = self.convertLinks(text.strip(), imagepage.site()) date = self.getUploadDate(imagepage)
pywikibot-commits@lists.wikimedia.org