jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1150499?usp=email )
Change subject: [doc] Fix documentation of Page.getDeletedRevision()
......................................................................
[doc] Fix documentation of Page.getDeletedRevision()
Bug: T331422
Change-Id: Ia956a89ba7174311ec4624902a6ee99870ca0b73
---
M pywikibot/page/_basepage.py
1 file changed, 32 insertions(+), 6 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py
index f61408f..58ede58 100644
--- a/pywikibot/page/_basepage.py
+++ b/pywikibot/page/_basepage.py
@@ -12,7 +12,7 @@
from contextlib import suppress
from itertools import islice
from textwrap import shorten, wrap
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Any, NoReturn
from urllib.parse import quote_from_bytes
from warnings import warn
@@ -2079,16 +2079,42 @@
timestamp,
content: bool = False,
**kwargs
- ) -> list:
+ ) -> dict[str, Any] | list[NoReturn]:
"""Return a particular deleted revision by timestamp.
+ Gives a dictionary with `revid`, `parentid`, `user`, `timestamp`,
+ and `comment` as keys like this:
+
+ .. code:: Python
+
+ {'revid': 658621, 'parentid': 0, 'user': 'Pywikibot-test',
+ 'timestamp': '2025-05-24T11:01:25Z',
+ 'comment': 'Pywikibot unit test'}
+
+ If *content* is True, a `slots` key is added which holds
+ additional information of the content like:
+
+ .. code:: Python
+
+ 'slots': {
+ 'main': {
+ 'contentmodel': 'wikitext',
+ 'contentformat': 'text/x-wiki',
+ '*': 'Pywikibot deletion test.'
+ }
+ }
+
+ .. caution::
+ If *timestamp* is not found, an empty **list** is given.
+
.. seealso:: :meth:`APISite.deletedrevs()
<pywikibot.site._generators.GeneratorsMixin.deletedrevs>`
- :return: a list of [date, editor, comment, text, restoration
- marker]. text will be None, unless content is True (or has
- been retrieved earlier). If timestamp is not found, returns
- empty list.
+ :param timestamp: Timestamp of the deleted revision
+ :param content: If True, give also the content of the deleted
+ revision.
+ :return: a dictionary information about the deleted revision. If
+ timestamp is not found, an empty list is given.
"""
if hasattr(self, '_deletedRevs') \
and timestamp in self._deletedRevs \
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1150499?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: Ia956a89ba7174311ec4624902a6ee99870ca0b73
Gerrit-Change-Number: 1150499
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Bináris <wikiposta(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1147773?usp=email )
Change subject: doc: Update documentation
......................................................................
doc: Update documentation
Change-Id: I2260e9dfdaccac52fde2fdd46dfe9b14c0df0524
---
M HISTORY.rst
M pywikibot/page/_user.py
M pywikibot/tools/__init__.py
3 files changed, 27 insertions(+), 4 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/HISTORY.rst b/HISTORY.rst
index cd0b0ab..ac36765 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -329,6 +329,8 @@
only available for :class:`family.WikimediaFamily` families. The ``wikimedia_sites.py`` maintenance script was
removed.
* Add :func:`config.base_dir<config.get_base_dir>` to scripts search path with :mod:`pwb` wrapper (:phab:`T324287`)
+* Detect range blocks with :meth:`pywikibot.User.is_blocked` and :meth:`pywikibot.User.getprops` (:phab:`T301282`)
+* Add :func:`tools.is_ip_network` and :meth:`pywikibot.User.is_CIDR` (:phab:`T301282`)
* :meth:`pywikibot.WbTime.equal_instant` was added (:phab:`T325248`)
* ``revisions`` parameter of :class:`xmlreader.XmlDump` was introduced to specify parsing method
(:phab:`T340804`)
diff --git a/pywikibot/page/_user.py b/pywikibot/page/_user.py
index 9f20a8d..1a4ba58 100644
--- a/pywikibot/page/_user.py
+++ b/pywikibot/page/_user.py
@@ -1,6 +1,6 @@
"""Object representing a Wiki user."""
#
-# (C) Pywikibot team, 2009-2024
+# (C) Pywikibot team, 2009-2025
#
# Distributed under the terms of the MIT license.
#
@@ -72,6 +72,8 @@
The page does not need to exist for this method to return
True.
+ .. seealso:: :meth:`isAnonymous`
+
:param force: if True, forces reloading the data from API
"""
# T135828: the registration timestamp may be None but the key exists
@@ -79,16 +81,32 @@
and 'registration' in self.getprops(force))
def isAnonymous(self) -> bool: # noqa: N802
- """Determine if the user is editing as an IP address."""
+ """Determine if the user is editing as an IP address.
+
+ .. seealso::
+ - :meth:`isRegistered`
+ - :meth:`is_CIDR`
+ - :func:`tools.is_ip_address`
+ """
return is_ip_address(self.username)
def is_CIDR(self) -> bool: # noqa: N802
- """Determine if the input refers to a range of IP addresses."""
+ """Determine if the input refers to a range of IP addresses.
+
+ .. versionadded:: 9.0
+ .. seealso::
+ - :meth:`isRegistered`
+ - :meth:`isAnonymous`
+ - :func:`tools.is_ip_network`
+ """
return is_ip_network(self.username)
def getprops(self, force: bool = False) -> dict:
"""Return a properties about the user.
+ .. versionchanged:: 9.0
+ detect range blocks
+
:param force: if True, forces reloading the data from API
"""
if force and hasattr(self, '_userprops'):
@@ -127,7 +145,8 @@
"""Determine whether the user is currently blocked.
.. versionchanged:: 7.0
- renamed from :meth:`isBlocked` method,
+ renamed from :meth:`isBlocked` method
+ .. versionchanged:: 9.0
can also detect range blocks.
:param force: if True, forces reloading the data from API
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 2a49960..6eb0fe8 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -92,6 +92,7 @@
.. versionadded:: 6.1
Was renamed from ``is_IP()``.
+ .. seealso:: :func:`is_ip_network`
:param value: value to check
"""
@@ -106,6 +107,7 @@
"""Check if a value is a valid range of IPv4 or IPv6 addresses.
.. versionadded:: 9.0
+ .. seealso:: :func:`is_ip_address`
:param value: value to check
"""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1147773?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: I2260e9dfdaccac52fde2fdd46dfe9b14c0df0524
Gerrit-Change-Number: 1147773
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot