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
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1044726?usp=email )
Change subject: [doc] adjust logging functions in documentation
......................................................................
[doc] adjust logging functions in documentation
Change-Id: Ic035554ed64a492f6ddd8dffa0dcb24c40a7e017
---
M HISTORY.rst
M ROADMAP.rst
M pywikibot/bot.py
M pywikibot/tools/formatter.py
4 files changed, 6 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index 472eddc..1a23884 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -583,7 +583,7 @@
* L10N updates
* Circumvent circular import in tools module (:phab:`T306760`)
* Don't fix html inside syntaxhighlight parts in fixes.py (:phab:`T306723`)
-* Make layer parameter optional in `pywikibot.debug()` (:phab:`T85620`)
+* Make layer parameter optional in :func:`pywikibot.debug()<pywikibot.logging.debug>` (:phab:`T85620`)
* Retry for internal_api_error_DBQueryTimeoutError errors due to :phab:`T297708`
* Handle ParserError within xmlreader.XmlDump.parse() instead of raising an exception (:phab:`T306134`)
* XMLDumpOldPageGenerator is deprecated in favour of a `content` parameter (:phab:`T306134`)
diff --git a/ROADMAP.rst b/ROADMAP.rst
index ed7c20a..0f5073b 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -75,7 +75,7 @@
<pywikibot.site._apisite.APISite.linktrail>` instead
* 7.2.0: Positional arguments *decoder*, *layer* and *newline* for :mod:`logging` functions where dropped; keyword
arguments must be used instead.
-* 7.2.0: ``tb`` parameter of :func:`exception()<pywikibot.exception>` function was renamed to ``exc_info``
+* 7.2.0: ``tb`` parameter of :func:`exception()<pywikibot.logging.exception>` function was renamed to ``exc_info``
* 7.2.0: XMLDumpOldPageGenerator is deprecated in favour of a ``content`` parameter of
:func:`XMLDumpPageGenerator<pagegenerators.XMLDumpPageGenerator>` (:phab:`T306134`)
* 7.2.0: RedirectPageBot and NoRedirectPageBot bot classes are deprecated in favour of
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index cff70ef..a993a1a 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -366,8 +366,8 @@
* :python:`Python Logging Levels<library/logging.html#logging-levels>`
Accordingly, do **not** use print statements in bot code; instead,
- use :func:`pywikibot.output` function and other functions from
- :mod:`pywikibot.logging` module.
+ use :func:`pywikibot.info()<pywikibot.logging.info>` function and
+ other functions from :mod:`pywikibot.logging` module.
.. versionchanged:: 6.2
Different logfiles are used if multiple processes of the same
diff --git a/pywikibot/tools/formatter.py b/pywikibot/tools/formatter.py
index 6ad82f5..59c3ace 100644
--- a/pywikibot/tools/formatter.py
+++ b/pywikibot/tools/formatter.py
@@ -60,7 +60,8 @@
"""Output the text of the current sequence.
.. deprecated:: 9.0
- Use :func:`pywikibot.info` with *out* property
+ Use :func:`pywikibot.info()<pywikibot.logging.info>` with
+ :attr:`out` property.
"""
info(self.out)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1044726?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: Ic035554ed64a492f6ddd8dffa0dcb24c40a7e017
Gerrit-Change-Number: 1044726
Gerrit-PatchSet: 1
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/+/1044651?usp=email )
Change subject: [doc] keyword arguments are strictly recommended for logging functions.
......................................................................
[doc] keyword arguments are strictly recommended for logging functions.
Change-Id: I75bc98248125e4c20490ce7bb363c9f07930ded5
---
M ROADMAP.rst
M pywikibot/logging.py
2 files changed, 30 insertions(+), 20 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/ROADMAP.rst b/ROADMAP.rst
index e407eb6..ed7c20a 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -73,6 +73,8 @@
* 7.3.0: Old color escape sequences like ``\03{color}`` is deprecated in favour of new color format like <<color>>
* 7.3.0: ``linktrail`` method of :class:`family.Family` is deprecated; use :meth:`APISite.linktrail()
<pywikibot.site._apisite.APISite.linktrail>` instead
+* 7.2.0: Positional arguments *decoder*, *layer* and *newline* for :mod:`logging` functions where dropped; keyword
+ arguments must be used instead.
* 7.2.0: ``tb`` parameter of :func:`exception()<pywikibot.exception>` function was renamed to ``exc_info``
* 7.2.0: XMLDumpOldPageGenerator is deprecated in favour of a ``content`` parameter of
:func:`XMLDumpPageGenerator<pagegenerators.XMLDumpPageGenerator>` (:phab:`T306134`)
diff --git a/pywikibot/logging.py b/pywikibot/logging.py
index 6965fd6..225b30f 100644
--- a/pywikibot/logging.py
+++ b/pywikibot/logging.py
@@ -18,6 +18,10 @@
The function :func:`debug` only logs its messages, they are never
displayed on the user console. :func:`debug()` takes a required second
argument, which is a string indicating the debugging layer.
+
+.. seealso::
+ - :pyhow:`Logging HOWTO<logging>`
+ - :python:`Logging Cookbook<howto/logging-cookbook.html>`
"""
#
# (C) Pywikibot team, 2010-2024
@@ -85,9 +89,9 @@
**kwargs: Any) -> None:
"""Format output and send to the logging module.
- Helper function used by all the user-output convenience functions.
- It can be used to implement your own high-level output function with
- a different logging level.
+ Dispatch helper function used by all the user-output convenience
+ functions. It can be used to implement your own high-level output
+ function with a different logging level.
`msg` can contain special sequences to create colored output. These
consist of the color name in angle bracket, e. g. <<lightpurple>>.
@@ -97,21 +101,21 @@
the only argument that is useful is ``exc_info=True``, which causes
the log message to include an exception traceback.
+ .. versionchanged:: 7.2
+ Positional arguments for *decoder* and *newline* are deprecated;
+ keyword arguments should be used.
+
:param msg: The message to be printed.
:param args: Not used yet; prevents positional arguments except `msg`.
:param level: The logging level; supported by :func:`logoutput` only.
- :keyword newline: If newline is True (default), a line feed will be
- added after printing the msg.
- :type newline: bool
- :keyword layer: Suffix of the logger name separated by dot. By
+ :keyword bool newline: If newline is True (default), a line feed
+ will be added after printing the msg.
+ :keyword str layer: Suffix of the logger name separated by dot. By
default no suffix is used.
- :type layer: str
- :keyword decoder: If msg is bytes, this decoder is used to decode.
- Default is 'utf-8', fallback is 'iso8859-1'
- :type decoder: str
+ :keyword str decoder: If msg is bytes, this decoder is used to
+ decode. Default is 'utf-8', fallback is 'iso8859-1'
:param kwargs: For the other keyword arguments refer
:python:`Logger.debug()<library/logging.html#logging.Logger.debug>`
- and :pyhow:`logging-cookbook`
"""
# invoke any init routines
if _init_routines:
@@ -174,7 +178,9 @@
The arguments are interpreted as for :func:`logoutput`.
.. versionadded:: 7.2
- was renamed from :func:`output`.
+ was renamed from :func:`output`. Positional arguments for
+ *decoder* and *newline* are deprecated; keyword arguments should
+ be used. Keyword parameter *layer* was added.
.. seealso::
:python:`Logger.info()<library/logging.html#logging.Logger.info>`
@@ -189,7 +195,7 @@
.. versionchanged:: 7.2
was renamed to :func:`info`; `text` was renamed to `msg`; `msg`
paramerer may be omitted; only keyword arguments are allowed except
- for `msg`.
+ for `msg`. Keyword parameter *layer* was added.
.. seealso::
:python:`Logger.info()<library/logging.html#logging.Logger.info>`
"""
@@ -209,7 +215,8 @@
.. versionchanged:: 7.2
`text` was renamed to `msg`; `msg` parameter may be omitted;
- only keyword arguments are allowed except for `msg`.
+ only keyword arguments are allowed except for `msg`. Keyword
+ parameter *layer* was added.
.. seealso::
- :python:`Logger.log()<library/logging.html#logging.Logger.log>`
- https://en.wikipedia.org/wiki/Pipeline_%28Unix%29
@@ -227,7 +234,7 @@
.. versionchanged:: 7.2
`text` was renamed to `msg`; only keyword arguments are allowed
- except for `msg`.
+ except for `msg`. Keyword parameter *layer* was added.
.. seealso::
:python:`Logger.warning()<library/logging.html#logging.Logger.warning>`
"""
@@ -244,7 +251,7 @@
.. versionchanged:: 7.2
`text` was renamed to `msg`; only keyword arguments are allowed
- except for `msg`.
+ except for `msg`. Keyword parameter *layer* was added.
.. seealso::
:python:`Logger.error()<library/logging.html#logging.Logger.error>`
"""
@@ -260,7 +267,7 @@
.. versionchanged:: 7.2
`text` was renamed to `msg`; only keyword arguments are allowed
- except for `msg`.
+ except for `msg`. Keyword parameter *layer* was added.
.. seealso::
:python:`Logger.log()<library/logging.html#logging.Logger.log>`
"""
@@ -277,7 +284,7 @@
.. versionchanged:: 7.2
`text` was renamed to `msg`; only keyword arguments are allowed
- except for `msg`.
+ except for `msg`. Keyword parameter *layer* was added.
.. seealso::
:python:`Logger.critical()
<library/logging.html#logging.Logger.critical>`
@@ -329,7 +336,8 @@
.. versionchanged:: 7.2
only keyword arguments are allowed except for `msg`;
- `exc_info` keyword is to be used instead of `tb`.
+ `exc_info` keyword is to be used instead of `tb`. Keyword
+ parameter *layer* was added.
.. versionchanged:: 7.3
`exc_info` is True by default
.. seealso::
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1044651?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: I75bc98248125e4c20490ce7bb363c9f07930ded5
Gerrit-Change-Number: 1044651
Gerrit-PatchSet: 1
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/+/1044631?usp=email )
Change subject: [tests] Update TestProtectionBot.test_summary() test in test_protect
......................................................................
[tests] Update TestProtectionBot.test_summary() test in test_protect
The order may change in comment.
Bug: T367259
Change-Id: I20d8d3e9df6f4729cc4437f25cfd92fa0e708b66
---
M tests/protectbot_tests.py
1 file changed, 8 insertions(+), 5 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/tests/protectbot_tests.py b/tests/protectbot_tests.py
index aa3d5f9..30e46f6 100755
--- a/tests/protectbot_tests.py
+++ b/tests/protectbot_tests.py
@@ -53,12 +53,15 @@
'Unprotecting all pages from category Pywikibot Protect Test')
self.maxDiff = None
- self.assertEqual(
- rev[0].comment,
+ comment = rev[0].comment
+ self.assertTrue(comment.startswith(
'Protected "[[User:Sn1per/ProtectTest2]]": Bot: '
- 'Protecting all pages from category Pywikibot Protect Test ('
- '[Move=Allow only administrators] (indefinite) '
- '[Edit=Allow only administrators] (indefinite))')
+ 'Protecting all pages from category Pywikibot Protect Test'
+ ))
+ # the order may change, see T367259
+ for ptype in ('Edit', 'Move'):
+ self.assertIn(f'[{ptype}=Allow only administrators] (indefinite)',
+ comment)
if __name__ == '__main__':
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1044631?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: I20d8d3e9df6f4729cc4437f25cfd92fa0e708b66
Gerrit-Change-Number: 1044631
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot