jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1045815?usp=email )
Change subject: [doc] update ROADMAP.rst and CHANGELOG.rst
......................................................................
[doc] update ROADMAP.rst and CHANGELOG.rst
also update documentation in api.Request
Change-Id: I502ee447ac07f6c6ac118a54f1d0cbbf11a0f225
---
M ROADMAP.rst
M pywikibot/data/api/_requests.py
M scripts/CHANGELOG.rst
3 files changed, 42 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 0f5073b..b244348 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,6 +1,16 @@
Current Release Changes
=======================
+* No longer wait in :meth:`data.api.Request._http_request` for ``ImportError`` and ``NameError``
+* Replace ``requests.utils.urlparse`` with ``urllib.parse.urlparse`` in
+ :func:`comms.http.get_authentication` (:phab:`T367649`)
+* Show an appropiate message if ``requests_oauthlib`` package is required but missing (:phab:`T353387`)
+* Retry ``DBUnexpectedError`` in :meth:`data.api.Request._internal_api_error` (:phab:`T367383`)
+* Duplicated entries found in :mod:`pywikibot` were removed
+* Pass ``None`` instead of an empty string as *expiry* argument in
+ :meth:`site.APISite.protect()<pywikibot.site._apisite.APISite.protect>` (:phab:`T367176`)
+* Fix keyword argument in :meth:`Page.undelete()<page.BasePage.undelete>` when
+ calling :meth:`site.APISite.undelete()<pywikibot.site._apisite.APISite.undelete>` (:phab:`T367037`)
* Check whether :attr:`BaseBot.generator<bot.BaseBot.generator>` is None in :meth:`run()<bot.BaseBot.run>` method
* Add *namespaces* parameter to :meth:`Page.templates()<page.BasePage.templates>` and
:meth:`Page.itertemplates()<page.BasePage.itertemplates>` and require keyword arguments;
@@ -8,10 +18,12 @@
* Drop pheetools support for :mod:`proofreadpage` which is no longer available upstreams (:phab:`T366036`)
* Raise :exc:`exceptions.SectionError` if a section does not exists on a page (:phab:`T107141`)
* Retry api request on ServerError (:phab:`T364275`, :phab:`T364393`)
+* i18n updates
Current Deprecations
====================
+* 9.2.0: Imports of :mod:`logging` functions from :mod:`bot` module is deprecated and will be desupported
* 9.2.0: *total* argument in ``-logevents`` pagegenerators option is deprecated;
use ``-limit`` instead (:phab:`T128981`)
* 9.0.0: The *content* parameter of :meth:`proofreadpage.IndexPage.page_gen` is deprecated and will be ignored
diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py
index b5c4d5c..3a4d770 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -675,7 +675,8 @@
no wait cycles for :exc:`ImportError` and :exc:`NameError`.
:return: a tuple containing requests.Response object from
- http.request and use_get value
+ :func:`comms.http.request` and *use_get* value
+
:meta public:
"""
kwargs = {}
@@ -733,6 +734,8 @@
:return: a data dict
:raises pywikibot.exceptions.APIError: unknown action found
:raises pywikibot.exceptions.APIError: unknown query result type
+
+ :meta public:
"""
try:
result = response.json()
@@ -813,6 +816,8 @@
.. versionchanged:: 7.2
Return True to retry the current request and Falso to resume.
+
+ :meta public:
"""
retry = False
if 'warnings' not in result:
@@ -851,6 +856,8 @@
the warning is not handled.
.. versionadded:: 7.2
+
+ :meta public:
"""
warnings = {
'purge': ("You've exceeded your rate limit. "
@@ -896,7 +903,9 @@
def _internal_api_error(self, code, error, result) -> bool:
"""Check for ``internal_api_error_`` or readonly and retry.
- :raises pywikibot.exceptions.APIMWError: internal_api_error or readonly
+ :raises pywikibot.exceptions.APIMWError: internal_api_error or
+ readonly
+ :meta public:
"""
iae = 'internal_api_error_'
if not (code.startswith(iae) or code == 'readonly'):
@@ -911,13 +920,14 @@
# If the error key is in this table, it is probably a temporary
# problem, so we will retry the edit.
# TODO: T154011: 'ReadOnlyError' seems replaced by 'readonly'
- retry = class_name in ['DBConnectionError', # T64974
- 'DBQueryError', # T60158
- 'DBQueryTimeoutError', # T297708
- 'DBUnexpectedError', # T360930
- 'ReadOnlyError', # T61227
- 'readonly', # T154011
- ]
+ retry = class_name in [
+ 'DBConnectionError', # T64974
+ 'DBQueryError', # T60158
+ 'DBQueryTimeoutError', # T297708
+ 'DBUnexpectedError', # T360930
+ 'ReadOnlyError', # T61227
+ 'readonly', # T154011
+ ]
pywikibot.error('Detected MediaWiki API exception {}{}'
.format(e, '; retrying' if retry else '; raising'))
@@ -1184,6 +1194,8 @@
remove Python main version from directoy name
:return: base directory path for cache entries
+
+ :meta public:
"""
path = Path(config.base_dir, 'apicache')
cls._make_dir(path)
@@ -1203,6 +1215,8 @@
:param dir_name: directory path
:return: directory path as `pathlib.Path` object for test purpose
+
+ :meta public:
"""
if isinstance(dir_name, str):
dir_name = Path(dir_name)
@@ -1242,6 +1256,8 @@
.. versionchanged:: 8.0
return a `pathlib.Path` object.
+
+ :meta public:
"""
return CachedRequest._get_cache_dir() / self._create_file_name()
diff --git a/scripts/CHANGELOG.rst b/scripts/CHANGELOG.rst
index 608b830..45d2b18 100644
--- a/scripts/CHANGELOG.rst
+++ b/scripts/CHANGELOG.rst
@@ -11,6 +11,11 @@
* Use transclusions of Information template as default generator
* Preload pages to make the script upto 10 times faster
+illustrate_wikidata
+^^^^^^^^^^^^^^^^^^^
+
+* ``-always`` option is supported
+
interwikidata
^^^^^^^^^^^^^
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1045815?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I502ee447ac07f6c6ac118a54f1d0cbbf11a0f225
Gerrit-Change-Number: 1045815
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <dalangi-ctr(a)wikimedia.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1045721?usp=email )
Change subject: [IMPR] No longer wait in Requests._http_request for ImportError and NameError
......................................................................
[IMPR] No longer wait in Requests._http_request for ImportError and NameError
Neither ImportError nor NameError can eb fixed by just waiting and retry.
raise the exception and leave in such case
Change-Id: I087b6c3106fd625036e719a1a371a7d3080215e5
---
M pywikibot/comms/http.py
M pywikibot/data/api/_requests.py
2 files changed, 20 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index ef4cc61..a61d464 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -432,8 +432,10 @@
auth = get_authentication(uri)
if auth is not None and len(auth) == 4:
if isinstance(requests_oauthlib, ImportError):
- pywikibot.error(requests_oauthlib)
- sys.exit(1)
+ raise ModuleNotFoundError(f"""{requests_oauthlib}. Install it with
+
+ pip install requests_oauthlib
+""")
else:
auth = requests_oauthlib.OAuth1(*auth)
diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py
index 8ce916d..b5c4d5c 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -13,6 +13,7 @@
import pickle
import pprint
import re
+import sys
import traceback
from collections.abc import MutableMapping
from contextlib import suppress
@@ -670,9 +671,12 @@
.. versionchanged:: 8.2
change the scheme if the previous request didn't have json
content.
+ .. versionchanged:: 9.2
+ no wait cycles for :exc:`ImportError` and :exc:`NameError`.
:return: a tuple containing requests.Response object from
http.request and use_get value
+ :meta public:
"""
kwargs = {}
schemes = ('http', 'https')
@@ -686,6 +690,7 @@
data=data, headers=headers, **kwargs)
except Server504Error:
pywikibot.log('Caught HTTP 504 error; retrying')
+
except Client414Error:
if use_get:
pywikibot.log('Caught HTTP 414 error; retrying')
@@ -694,17 +699,25 @@
pywikibot.warning(
'Caught HTTP 414 error, although not using GET.')
raise
- except (ConnectionError, FatalServerError):
- # This error is not going to be fixed by just waiting
- pywikibot.error(traceback.format_exc())
+
+ except (ConnectionError, FatalServerError, NameError):
+ # These errors are not going to be fixed by just waiting
raise
+
+ except ImportError as e:
+ # Leave the script gracefully
+ pywikibot.error(e)
+ sys.exit(1)
+
# TODO: what other exceptions can occur here?
except Exception:
# for any other error on the http request, wait and retry
pywikibot.error(traceback.format_exc())
pywikibot.log(f'{uri}, {paramstring}')
+
else:
return response, use_get
+
self.wait()
return None, use_get
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1045721?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I087b6c3106fd625036e719a1a371a7d3080215e5
Gerrit-Change-Number: 1045721
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1045496?usp=email )
Change subject: [IMPR] replace requests.utils.urlparse with urllib.parse.urlparse
......................................................................
[IMPR] replace requests.utils.urlparse with urllib.parse.urlparse
requests.utils.urlparse is not part of the official API and it is used
within requests for Python 3 support,
Bug: T367649
Change-Id: If29b1fd6e3cceb64163ae0662e69ac31fc685b19
---
M pywikibot/comms/http.py
1 file changed, 10 insertions(+), 11 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 65f1333..ef4cc61 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -26,7 +26,7 @@
Cookies are lazy loaded when logging to site.
"""
#
-# (C) Pywikibot team, 2007-2023
+# (C) Pywikibot team, 2007-2024
#
# Distributed under the terms of the MIT license.
#
@@ -286,26 +286,25 @@
def get_authentication(uri: str) -> tuple[str, str] | None:
- """
- Retrieve authentication token.
+ """Retrieve authentication token.
:param uri: the URI to access
:return: authentication token
"""
- parsed_uri = requests.utils.urlparse(uri)
+ parsed_uri = urlparse(uri)
netloc_parts = parsed_uri.netloc.split('.')
netlocs = [parsed_uri.netloc] + ['.'.join(['*'] + netloc_parts[i + 1:])
for i in range(len(netloc_parts))]
for path in netlocs:
if path in config.authenticate:
- if len(config.authenticate[path]) in [2, 4]:
+ length = len(config.authenticate[path])
+ if length in (2, 4):
return config.authenticate[path]
- warn('config.authenticate["{path}"] has invalid value.\n'
- 'It should contain 2 or 4 items, not {length}.\n'
- 'See {url}/OAuth for more info.'
- .format(path=path,
- length=len(config.authenticate[path]),
- url=pywikibot.__url__))
+
+ warn(f'config.authenticate[{path!r}] has invalid value.\n'
+ f'It should contain 2 or 4 items, not {length}.\n'
+ f'See {pywikibot.__url__}/OAuth for more info.')
+
return None
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1045496?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If29b1fd6e3cceb64163ae0662e69ac31fc685b19
Gerrit-Change-Number: 1045496
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1044742?usp=email )
Change subject: [doc] Markup and references fixes
......................................................................
[doc] Markup and references fixes
Change-Id: I84cff595df13bc5e56a9f50174a3ddae327fb9dd
---
M pywikibot/site/_apisite.py
M pywikibot/site/_generators.py
2 files changed, 4 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 5ca39e4..9a2037c 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -2013,6 +2013,7 @@
* unwatch --- remove the page from the watchlist
* preferences --- use the preference settings (default)
* nochange --- don't change the watchlist
+
If None (default), follow bot account's default settings
:param bot: if True, mark edit with bot flag
@@ -2028,7 +2029,7 @@
:raises AbuseFilterDisallowedError: This action has been
automatically identified as harmful, and therefore disallowed
:raises CaptchaError: :ref:`config.solve_captcha
- <pywikibot.config#account-settings>` is False and saving the
+ <Account Settings>` is False and saving the
page requires solving a captcha
:raises CascadeLockedPageError: The page is protected with
protection cascade
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index 4544e8c..8b1221d 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -2310,7 +2310,8 @@
'query+protectedtitles' module.
.. versionchanged:: 9.0
- *type* parameter was renamed to *protect_type*.
+ *type* parameter was renamed to *protect_type*.
+
.. seealso:: :api:`Protectedtitles`
:param namespace: The searched namespace.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1044742?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I84cff595df13bc5e56a9f50174a3ddae327fb9dd
Gerrit-Change-Number: 1044742
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot