jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/563665 )
Change subject: [cleanup] remove weblib.py in favour of mementoclient ......................................................................
[cleanup] remove weblib.py in favour of mementoclient
The weblib function is broken. As announced in HISTORY.rst and FutureWarning it can be removed in favour of mementoclient
- remove weblib.py - update CONTENT.rst - update tests/__init__.py - update tox.ini
Bug: T85001 Change-Id: If44de02f9e4332620fadc6646bd355472c6dbe0a --- M HISTORY.rst M pywikibot/CONTENT.rst D pywikibot/weblib.py M tests/__init__.py M tox.ini 5 files changed, 2 insertions(+), 103 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst index c189bdb..7c79562 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,6 +5,7 @@ ---------------
* Category.copyTo and Category.copyAndKeep will be removed in the next release +* weblib module has been removed (T85001) * botirc module has been removed (T212632) * Bugfixes and improvements * Localisation updates diff --git a/pywikibot/CONTENT.rst b/pywikibot/CONTENT.rst index 2115533..213ec41 100644 --- a/pywikibot/CONTENT.rst +++ b/pywikibot/CONTENT.rst @@ -78,9 +78,6 @@ | version.py | Module to determine the pywikibot version (tag, | | | revision and date) | +----------------------------+------------------------------------------------------+ - | weblib.py | Functions for manipulating external links or | - | | querying third-party sites | - +----------------------------+------------------------------------------------------+ | xmlreader.py | Reading and parsing XML dump files. | +----------------------------+------------------------------------------------------+
diff --git a/pywikibot/weblib.py b/pywikibot/weblib.py deleted file mode 100644 index 7d83592..0000000 --- a/pywikibot/weblib.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- -"""Functions for manipulating external links or querying third-party sites.""" -# -# (C) Pywikibot team, 2013-2019 -# -# Distributed under the terms of the MIT license. -# -from __future__ import absolute_import, division, unicode_literals - -import json -from time import sleep -from xml.etree import ElementTree - -from requests.exceptions import ConnectionError as RequestsConnectionError - -from pywikibot.comms import http -from pywikibot import config2 -from pywikibot.tools import issue_deprecation_warning, PY2 - -if not PY2: - from urllib.parse import urlencode -else: - from urllib import urlencode - -issue_deprecation_warning( - 'weblib', 'memento_client package', since='20150811', - warning_class=FutureWarning) - - -def getInternetArchiveURL(url, timestamp=None): - """Return archived URL by Internet Archive. - - See [[:mw:Archived Pages]] and https://archive.org/help/wayback_api.php - for more details. - - @param url: url to search an archived version for - @param timestamp: requested archive date. The version closest to that - moment is returned. Format: YYYYMMDDhhmmss or part thereof. - - """ - uri = 'https://archive.org/wayback/available?' - - query = {'url': url} - - if timestamp is not None: - query['timestamp'] = timestamp - - uri = uri + urlencode(query) - - retry_count = 0 - while retry_count <= config2.max_retries: - try: - jsontext = http.fetch(uri).text - break - except RequestsConnectionError as e: - error = e - retry_count += 1 - sleep(config2.retry_wait) - else: - raise error - - if 'closest' in jsontext: - data = json.loads(jsontext) - return data['archived_snapshots']['closest']['url'] - else: - return None - - -def getWebCitationURL(url, timestamp=None): - """Return archived URL by Web Citation. - - See http://www.webcitation.org/doc/WebCiteBestPracticesGuide.pdf - for more details - - @param url: url to search an archived version for - @param timestamp: requested archive date. The version closest to that - moment is returned. Format: YYYYMMDDhhmmss or part thereof. - - """ - uri = 'http://www.webcitation.org/query?' - - query = {'returnxml': 'true', - 'url': url} - - if timestamp is not None: - query['date'] = timestamp - - uri = uri + urlencode(query) - xmltext = http.fetch(uri).text - if 'success' in xmltext: - data = ElementTree.fromstring(xmltext) - return data.find('.//webcite_url').text - else: - return None diff --git a/tests/__init__.py b/tests/__init__.py index 2c67e84..89b57fc 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Package tests.""" # -# (C) Pywikibot team, 2007-2019 +# (C) Pywikibot team, 2007-2020 # # Distributed under the terms of the MIT license. # @@ -156,9 +156,6 @@ 'textlib': [ 'test_interwiki_format', # example; very slow test ], - 'weblib': [ - 'testWebCiteOlder', # fails. T110640 - ], }
diff --git a/tox.ini b/tox.ini index ceed4e8..eee632d 100644 --- a/tox.ini +++ b/tox.ini @@ -158,7 +158,6 @@ pywikibot/userinterfaces/terminal_interface_win32.py : E241, N816 pywikibot/userinterfaces/transliteration.py : N801 pywikibot/userinterfaces/win32_unicode.py : N801, N812, T001, N803, N806 - pywikibot/weblib.py: N802 pywikibot/xmlreader.py : N803, N806, N802 scripts/add_text.py : N803, N806 scripts/blockpageschecker.py : N802, N803, N806, N816 @@ -243,7 +242,6 @@ tests/ui_options_tests.py: N802 tests/ui_tests.py : D102, D103, N801, N802, N813 tests/utils.py: N802, N813 - tests/weblib_tests.py: N802 tests/wikibase_edit_tests.py: N802 tests/wikibase_tests.py: N802 tests/xmlreader_tests.py: N802