jenkins-bot submitted this change.
[cleanup] Use FutureWarning for methods deprecated for 6 years
Bug: T106121
Change-Id: I466f39b32907f6bc76637709ff99518ebb7d58ac
---
M pywikibot/__init__.py
M pywikibot/bot.py
M pywikibot/data/api.py
M pywikibot/family.py
M pywikibot/page/__init__.py
M pywikibot/pagegenerators.py
M pywikibot/site/__init__.py
M pywikibot/specialbots/_upload.py
M scripts/category.py
9 files changed, 95 insertions(+), 70 deletions(-)
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index b88303e..3a59e89 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -108,7 +108,7 @@
for _name in textlib_methods:
target = getattr(textlib, _name)
- wrapped_func = redirect_func(target, since='20140820')
+ wrapped_func = redirect_func(target, since='20140820', future_warning=True)
globals()[_name] = wrapped_func
@@ -199,7 +199,8 @@
return self.strftime(self._ISO8601Format(sep))
toISOformat = redirect_func(isoformat, old_name='toISOformat',
- class_name='Timestamp', since='20141219')
+ class_name='Timestamp', since='20141219',
+ future_warning=True)
def totimestampformat(self):
"""Convert object to a MediaWiki internal timestamp."""
@@ -1279,7 +1280,8 @@
link_regex = re.compile(r'\[\[(?P<title>[^\]|[<>{}]*)(\|.*?)?\]\]')
-@__deprecated('comment parameter for page saving method', since='20140604')
+@__deprecated('comment parameter for page saving method', since='20140604',
+ future_warning=True)
def setAction(s):
"""Set a summary to use for changed page submissions."""
config.default_edit_summary = s
@@ -1409,7 +1411,8 @@
_putthread.setDaemon(True)
wrapper = _ModuleDeprecationWrapper(__name__)
-wrapper._add_deprecated_attr('ImagePage', FilePage, since='20140924')
+wrapper._add_deprecated_attr('ImagePage', FilePage, since='20140924',
+ future_warning=True)
wrapper._add_deprecated_attr(
'cookie_jar', replacement_name='pywikibot.comms.http.cookie_jar',
since='20150921')
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 00beb75..2c3e105 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -507,7 +507,7 @@
automatic_quit=automatic_quit, force=force)
-@deprecated('input_choice', since='20140825')
+@deprecated('input_choice', since='20140825', future_warning=True)
def inputChoice(question, answers, hotkeys, default=None):
"""Ask the user a question with several options, return the user's choice.
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 217fc51..11b8826 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -2933,7 +2933,7 @@
return p
-@deprecated('PageGenerator', since='20141106')
+@deprecated('PageGenerator', since='20141106', future_warning=True)
class CategoryPageGenerator(PageGenerator):
"""Like PageGenerator, but yields Category objects instead of Pages."""
@@ -2941,7 +2941,7 @@
pass
-@deprecated('PageGenerator', since='20141106')
+@deprecated('PageGenerator', since='20141106', future_warning=True)
class ImagePageGenerator(PageGenerator):
"""Like PageGenerator, but yields FilePage objects instead of Pages."""
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 1e28023..bb806d0 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1122,7 +1122,7 @@
return repo.code, repo.family.name
return (None, None)
- @deprecated('Site.server_time()', since='20141225')
+ @deprecated('Site.server_time()', since='20141225', future_warning=True)
def server_time(self, code):
"""
DEPRECATED, use Site.server_time instead.
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index a45192b..03c741f 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -911,7 +911,7 @@
"""Return True if the page is a Category, False otherwise."""
return self.namespace() == 14
- @deprecated('is_categorypage', since='20140819')
+ @deprecated('is_categorypage', since='20140819', future_warning=True)
def isCategory(self):
"""DEPRECATED: use is_categorypage instead."""
return self.is_categorypage()
@@ -920,7 +920,7 @@
"""Return True if this is an file description page, False otherwise."""
return self.namespace() == 6
- @deprecated('is_filepage', since='20140819')
+ @deprecated('is_filepage', since='20140819', future_warning=True)
def isImage(self):
"""DEPRECATED: use is_filepage instead."""
return self.is_filepage()
@@ -1579,7 +1579,7 @@
return ItemPage.fromPage(self)
@deprecate_arg('tllimit', None)
- @deprecated('Page.templates()', since='20140421')
+ @deprecated('Page.templates()', since='20140421', future_warning=True)
def getTemplates(self):
"""DEPRECATED. Use templates()."""
return self.templates()
@@ -1863,7 +1863,7 @@
cnt = self.contributors()
return sum(cnt[username] for username in contributors)
- @deprecated('oldest_revision', since='20140421')
+ @deprecated('oldest_revision', since='20140421', future_warning=True)
def getCreator(self):
"""
Get the first revision of the page.
@@ -2611,7 +2611,8 @@
return self.latest_file_info.url.startswith(
'https://upload.wikimedia.org/wikipedia/commons/')
- @deprecated('FilePage.latest_file_info.sha1', since='20141106')
+ @deprecated('FilePage.latest_file_info.sha1', since='20141106',
+ future_warning=True)
def getFileMd5Sum(self):
"""Return image file's MD5 checksum."""
req = http.fetch(self.fileUrl())
@@ -2619,7 +2620,8 @@
h.update(req.raw)
return h.hexdigest()
- @deprecated('FilePage.latest_file_info.sha1', since='20141106')
+ @deprecated('FilePage.latest_file_info.sha1', since='20141106',
+ future_warning=True)
def getFileSHA1Sum(self):
"""Return the file's SHA1 checksum."""
return self.latest_file_info.sha1
@@ -2634,7 +2636,8 @@
return [self.oldest_file_info.user,
self.oldest_file_info.timestamp.isoformat()]
- @deprecated('FilePage.latest_file_info.user', since='20141106')
+ @deprecated('FilePage.latest_file_info.user', since='20141106',
+ future_warning=True)
def getLatestUploader(self) -> list:
"""
Return a list with latest uploader of the FilePage and timestamp.
@@ -2644,7 +2647,8 @@
return [self.latest_file_info.user,
self.latest_file_info.timestamp.isoformat()]
- @deprecated('FilePage.get_file_history()', since='20141106')
+ @deprecated('FilePage.get_file_history()', since='20141106',
+ future_warning=True)
def getFileVersionHistory(self):
"""
Return the file's version history.
@@ -2798,10 +2802,6 @@
return self.site.globalusage(self, total=total)
-wrapper = _ModuleDeprecationWrapper(__name__)
-wrapper._add_deprecated_attr('ImagePage', FilePage, since='20140924')
-
-
class Category(Page):
"""A page in the Category: namespace."""
@@ -3391,7 +3391,7 @@
return True
return False
- @deprecated('send_email', since='20141218')
+ @deprecated('send_email', since='20141218', future_warning=True)
def sendMail(self, subject, text, ccme=False):
"""
Send an email to this user via MediaWiki's email interface.
@@ -6840,3 +6840,8 @@
first_exception = ex
# Couldn't convert, raise the original exception
raise first_exception
+
+
+wrapper = _ModuleDeprecationWrapper(__name__)
+wrapper._add_deprecated_attr('ImagePage', FilePage, since='20140924',
+ future_warning=True)
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index b15f73b..f0f84c2 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -1222,7 +1222,8 @@
@deprecated('Site.allpages()', since='20180512')
@deprecated_args(step=None)
def AllpagesPageGenerator(start='!', namespace=0, includeredirects=True,
- site=None, total=None, content=False):
+ site=None, total=None, content=False
+ ): # pragma: no cover
"""
Iterate Page objects for all titles in a single namespace.
@@ -1327,7 +1328,7 @@
pywikibot.exception(e)
-@deprecated('LogeventsPageGenerator', since='20141210')
+@deprecated('LogeventsPageGenerator', since='20141210', future_warning=True)
@deprecated_args(number='total', mode='logtype', repeat=None)
def LogpagesPageGenerator(total=500, logtype='', user=None,
site=None, namespace=[]):
@@ -1349,7 +1350,8 @@
@type total: int
"""
return LogeventsPageGenerator(total=total, logtype=logtype, user=user,
- site=site, namespace=namespace)
+ site=site,
+ namespace=namespace) # pragma: no cover
@deprecated_args(number='total', step=None, namespace='namespaces',
@@ -1466,14 +1468,16 @@
@deprecated_args(referredImagePage='referredFilePage', step=None)
def FileLinksGenerator(referredFilePage, total=None, content=False):
"""DEPRECATED. Yield Pages on which referredFilePage file is displayed."""
- return referredFilePage.usingPages(total=total, content=content)
+ return referredFilePage.usingPages(total=total,
+ content=content) # pragma: no cover
@deprecated('Page.imagelinks()', since='20200515')
@deprecated_args(step=None)
def ImagesPageGenerator(pageWithImages, total=None, content=False):
"""DEPRECATED. Yield FilePages displayed on pageWithImages."""
- return pageWithImages.imagelinks(total=total, content=content)
+ return pageWithImages.imagelinks(total=total,
+ content=content) # pragma: no cover
def InterwikiPageGenerator(page):
@@ -1579,7 +1583,8 @@
linkingPage
@rtype: generator
"""
- return linkingPage.linkedPages(total=total, content=content)
+ return linkingPage.linkedPages(total=total,
+ content=content) # pragma: no cover
def TextfilePageGenerator(filename=None, site=None):
@@ -2097,7 +2102,7 @@
@deprecated('itertools.chain(*iterables)', since='20180513')
def CombinedPageGenerator(generators):
"""Yield from each iterable until exhausted, then proceed with the next."""
- return itertools.chain(*generators)
+ return itertools.chain(*generators) # pragma: no cover
def PageClassGenerator(generator):
@@ -2327,7 +2332,7 @@
@deprecated('Site.unusedfiles()', since='20200515')
@deprecated_args(extension=None, number='total', repeat=None)
-def UnusedFilesGenerator(total=None, site=None):
+def UnusedFilesGenerator(total=None, site=None): # pragma: no cover
"""
DEPRECATED. Unused files generator.
@@ -2343,7 +2348,7 @@
@deprecated('Site.withoutinterwiki()', since='20200515')
@deprecated_args(number='total', repeat=None)
-def WithoutInterwikiPageGenerator(total=None, site=None):
+def WithoutInterwikiPageGenerator(total=None, site=None): # pragma: no cover
"""
DEPRECATED. Page lacking interwikis generator.
@@ -2358,7 +2363,7 @@
@deprecated('Site.uncategorizedcategories()', since='20200515')
@deprecated_args(number='total', repeat=None)
-def UnCategorizedCategoryGenerator(total=100, site=None):
+def UnCategorizedCategoryGenerator(total=100, site=None): # pragma: no cover
"""
DEPRECATED. Uncategorized category generator.
@@ -2374,7 +2379,7 @@
@deprecated('Site.uncategorizedimages()', since='20200515')
@deprecated_args(number='total', repeat=None)
-def UnCategorizedImageGenerator(total=100, site=None):
+def UnCategorizedImageGenerator(total=100, site=None): # pragma: no cover
"""
DEPRECATED. Uncategorized file generator.
@@ -2390,7 +2395,7 @@
@deprecated('Site.uncategorizedpages()', since='20200515')
@deprecated_args(number='total', repeat=None)
-def UnCategorizedPageGenerator(total=100, site=None):
+def UnCategorizedPageGenerator(total=100, site=None): # pragma: no cover
"""
DEPRECATED. Uncategorized page generator.
@@ -2406,7 +2411,7 @@
@deprecated('Site.uncategorizedtemplates()', since='20200515')
@deprecated_args(number='total', repeat=None)
-def UnCategorizedTemplateGenerator(total=100, site=None):
+def UnCategorizedTemplateGenerator(total=100, site=None): # pragma: no cover
"""
DEPRECATED. Uncategorized template generator.
@@ -2422,7 +2427,7 @@
@deprecated('Site.lonelypages()', since='20200515')
@deprecated_args(number='total', repeat=None)
-def LonelyPagesPageGenerator(total=None, site=None):
+def LonelyPagesPageGenerator(total=None, site=None): # pragma: no cover
"""
DEPRECATED. Lonely page generator.
@@ -2438,7 +2443,7 @@
@deprecated('Site.unwatchedpages()', since='20200515')
@deprecated_args(number='total', repeat=None)
-def UnwatchedPagesPageGenerator(total=None, site=None):
+def UnwatchedPagesPageGenerator(total=None, site=None): # pragma: no cover
"""
DEPRECATED. Unwatched page generator.
@@ -2453,7 +2458,8 @@
@deprecated('Site.pages_with_property()', since='20200515')
-def page_with_property_generator(name, total=None, site=None):
+def page_with_property_generator(name, total=None,
+ site=None): # pragma: no cover
"""
Special:PagesWithProperty page generator.
@@ -2470,7 +2476,7 @@
@deprecated('Site.wantedpages', since='20180803')
-def WantedPagesPageGenerator(total=100, site=None):
+def WantedPagesPageGenerator(total=100, site=None): # pragma: no cover
"""
Wanted page generator.
@@ -2485,7 +2491,7 @@
@deprecated_args(number='total', repeat=None)
-def AncientPagesPageGenerator(total=100, site=None):
+def AncientPagesPageGenerator(total=100, site=None): # pragma: no cover
"""
Ancient page generator.
@@ -2501,7 +2507,7 @@
@deprecated('Site.deadendpages()', since='20200515')
@deprecated_args(number='total', repeat=None)
-def DeadendPagesPageGenerator(total=100, site=None):
+def DeadendPagesPageGenerator(total=100, site=None): # pragma: no cover
"""
DEPRECATED. Dead-end page generator.
@@ -2547,7 +2553,8 @@
@deprecated('Site.randompages()', since='20200515')
@deprecated_args(number='total')
-def RandomPageGenerator(total=None, site=None, namespaces=None):
+def RandomPageGenerator(total=None, site=None,
+ namespaces=None): # pragma: no cover
"""
DEPRECATED. Random page generator.
@@ -2563,7 +2570,8 @@
@deprecated('Site.randompages()', since='20200515')
@deprecated_args(number='total')
-def RandomRedirectPageGenerator(total=None, site=None, namespaces=None):
+def RandomRedirectPageGenerator(total=None, site=None,
+ namespaces=None): # pragma: no cover
"""
DEPRECATED. Random redirect generator.
@@ -2606,7 +2614,8 @@
@deprecated('Site.search()', since='20200515')
@deprecated_args(number='total', step=None)
-def SearchPageGenerator(query, total=None, namespaces=None, site=None):
+def SearchPageGenerator(query, total=None, namespaces=None,
+ site=None): # pragma: no cover
"""
DEPRECATED. Yield pages from the MediaWiki internal search engine.
@@ -3080,19 +3089,18 @@
PageClassGenerator, old_name='CategoryGenerator', since='20161017')
UnCategorizedTemplatesGenerator = redirect_func(
UnCategorizedTemplateGenerator, old_name='UnCategorizedTemplatesGenerator',
- since='20141225')
+ since='20141225', future_warning=True)
RecentchangesPageGenerator = redirect_func(
RecentChangesPageGenerator, old_name='RecentchangesPageGenerator',
- since='20141225')
+ since='20141225', future_warning=True)
# Deprecated old names from Pywikibot 2.0 beta1
WikidataItemGenerator = redirect_func(
- WikibaseItemGenerator, old_name='WikidataItemGenerator', since='20141225')
-
-
-if __name__ == '__main__':
- pywikibot.output('Pagegenerators cannot be run as script - are you '
- 'looking for listpages.py?')
-
+ WikibaseItemGenerator, old_name='WikidataItemGenerator',
+ since='20141225', future_warning=True)
wrapper = ModuleDeprecationWrapper(__name__)
wrapper._add_deprecated_attr('YahooSearchPageGenerator', replacement_name='',
since='20181128')
+
+if __name__ == '__main__': # pragma: no cover
+ pywikibot.output('Pagegenerators cannot be run as script - are you '
+ 'looking for listpages.py?')
diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py
index ea208a0..6e8b129 100644
--- a/pywikibot/site/__init__.py
+++ b/pywikibot/site/__init__.py
@@ -1028,7 +1028,7 @@
normalizeNamespace = redirect_func(ns_normalize,
old_name='normalizeNamespace',
class_name='BaseSite',
- since='20141001')
+ since='20141001', future_warning=True)
@remove_last_args(('default', ))
def redirect(self):
@@ -1229,7 +1229,7 @@
return api.encode_url(query)
@deprecated('pywikibot.data.api.Request or pywikibot.comms.http.request',
- since='20141225')
+ since='20141225', future_warning=True)
@deprecated_args(compress=None, no_hostname=None, cookies_only=None,
refer=None, back_response=None, retry=None, sysop=None)
def getUrl(self, path, data=None):
@@ -1247,13 +1247,13 @@
else:
return http.request(self, path)
- @deprecated(since='20141225')
+ @deprecated(since='20141225', future_warning=True)
@remove_last_args(['sysop', 'cookies'])
def postForm(self, address, predata):
"""DEPRECATED."""
return self.getUrl(address, data=predata)
- @deprecated(since='20141225')
+ @deprecated(since='20141225', future_warning=True)
@deprecated_args(contentType=None)
@remove_last_args(['sysop', 'compress', 'cookies'])
def postData(self, address, data):
@@ -2063,7 +2063,8 @@
# alias for backward-compatibility
forceLogin = redirect_func(login, old_name='forceLogin',
- class_name='APISite', since='20141001')
+ class_name='APISite', since='20141001',
+ future_warning=True)
def _relogin(self):
"""Force a login sequence without logging out, using the current user.
@@ -2187,7 +2188,8 @@
"""
return 'blockinfo' in self.userinfo
- @deprecated('has_right() or is_blocked()', since='20141218')
+ @deprecated('has_right() or is_blocked()', since='20141218',
+ future_warning=True)
@remove_last_args(['sysop'])
def checkBlocks(self):
"""
@@ -2562,7 +2564,8 @@
self.expand_text('{{CURRENTTIMESTAMP}}'))
getcurrenttime = redirect_func(server_time, old_name='getcurrenttime',
- class_name='APISite', since='20141225')
+ class_name='APISite', since='20141225',
+ future_warning=True)
def getmagicwords(self, word):
"""Return list of localized "word" magic words for the site."""
@@ -2654,7 +2657,7 @@
return _namespaces
- @deprecated('has_extension', since='20140819')
+ @deprecated('has_extension', since='20140819', future_warning=True)
@remove_last_args(('unknown', ))
def hasExtension(self, name, unknown=None):
"""DEPRECATED. Determine whether extension `name` is loaded."""
@@ -2926,7 +2929,7 @@
return self.namespaces[num]
return self.namespaces[num][0]
- @deprecated('version()', since='20140612')
+ @deprecated('version()', since='20140612', future_warning=True)
def live_version(self, force=False):
"""Return the 'real' version number found on [[Special:Version]].
@@ -3584,7 +3587,7 @@
return user_tokens
- @deprecated("the 'tokens' property", since='20140613')
+ @deprecated("the 'tokens' property", since='20140613', future_warning=True)
def token(self, page, tokentype):
"""Return token retrieved from wiki to allow changing page content.
@@ -4693,7 +4696,7 @@
return legen
- @deprecated('APISite.logevents()', since='20141225')
+ @deprecated('APISite.logevents()', since='20141225', future_warning=True)
@deprecated_args(repeat=None)
def logpages(self, number=50, mode=None, title=None, user=None,
namespace=None, start=None, end=None, tag=None, newer=False,
@@ -6728,7 +6731,8 @@
comment = event.comment() or ''
yield (filepage, date, user, comment)
- @deprecated('APISite.logevents(logtype="upload")', since='20140808')
+ @deprecated('APISite.logevents(logtype="upload")', since='20140808',
+ future_warning=True)
@deprecated_args(number='total', repeat=None)
def newimages(self, *args, **kwargs):
"""
@@ -6909,7 +6913,7 @@
"""
return self.querypage('Unusedimages', total)
- @deprecated('Site().unusedfiles()', since='20140808')
+ @deprecated('Site().unusedfiles()', since='20140808', future_warning=True)
@deprecated_args(extension=None, number='total', step=None, repeat=None)
def unusedimages(self, total=None):
"""Yield FilePage objects from Special:Unusedimages.
@@ -7550,9 +7554,11 @@
# aliases for backwards compatibility
isBlocked = redirect_func(is_blocked, old_name='isBlocked',
- class_name='APISite', since='20141218')
+ class_name='APISite', since='20141218',
+ future_warning=True)
isAllowed = redirect_func(has_right, old_name='isAllowed',
- class_name='APISite', since='20141218')
+ class_name='APISite', since='20141218',
+ future_warning=True)
class ClosedSite(APISite):
diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py
index 1b7cbdd..b4bef7d 100644
--- a/pywikibot/specialbots/_upload.py
+++ b/pywikibot/specialbots/_upload.py
@@ -387,7 +387,8 @@
else:
return warn_code in self.ignore_warning
- @deprecated('UploadRobot.upload_file()', since='20141211')
+ @deprecated('UploadRobot.upload_file()', since='20141211',
+ future_warning=True)
@deprecated_args(debug=True)
def upload_image(self):
"""Upload image."""
diff --git a/scripts/category.py b/scripts/category.py
index b491f99..f725d1c 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -892,7 +892,8 @@
CategoryMoveRobot without newcat param instead.
"""
- @deprecated('CategoryMoveRobot without newcat parameter', since='20140416')
+ @deprecated('CategoryMoveRobot without newcat parameter', since='20140416',
+ future_warning=True)
def __init__(
self, catTitle, batchMode=False, editSummary='',
useSummaryForDeletion=CategoryMoveRobot.DELETION_COMMENT_AUTOMATIC,
@@ -1548,4 +1549,5 @@
main()
wrapper = ModuleDeprecationWrapper(__name__)
-wrapper._add_deprecated_attr('AddCategory', CategoryAddBot, since='20140918')
+wrapper._add_deprecated_attr('AddCategory', CategoryAddBot, since='20140918',
+ future_warning=True)
To view, visit change 612544. To unsubscribe, or for help writing mail filters, visit settings.