jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1183264?usp=email )
Change subject: doc: Refactor docstrings of category.py script
......................................................................
doc: Refactor docstrings of category.py script
Change-Id: Ifd9dbdb9b5e4ac93341447311f4eecb981f8fe34
---
M scripts/category.py
1 file changed, 80 insertions(+), 31 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/category.py b/scripts/category.py
index 99f918b..8794727 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -472,16 +472,25 @@
self.comment = comment
@staticmethod
- def sorted_by_last_name(catlink, pagelink) -> pywikibot.Page:
- """Return a Category with key that sorts persons by their last name.
+ def sorted_by_last_name(catlink: pywikibot.Page,
+ pagelink: pywikibot.Page) -> pywikibot.Page:
+ """Return a category entry for a person, sorted by last name.
- Parameters: catlink - The Category to be linked.
- pagelink - the Page to be placed in the category.
+ If the page title contains a disambiguation suffix in brackets,
+ it will be removed. The last word of the (cleaned) title is
+ treated as the surname and moved to the front, separated by a
+ comma.
- Trailing words in brackets will be removed. Example: If
- category_name is 'Author' and pl is a Page to [[Alexandre Dumas
- (senior)]], this function will return this Category:
- [[Category:Author|Dumas, Alexandre]].
+ Example:
+ If *catlink* is ``Category:Author`` and *pagelink* points to
+ ``[[Alexandre Dumas (senior)]]``, this method returns::
+
+ [[Category:Author|Dumas, Alexandre]]
+
+ :param catlink: Category page where the entry should be added.
+ :param pagelink: Page of the person to be categorized.
+ :return: A page object representing the category entry with the
+ correct sort key.
"""
page_name = pagelink.title()
site = pagelink.site
@@ -1323,49 +1332,89 @@
"""Robot to create tree overviews of the category structure.
- Parameters:
- * cat_title - The category which will be the tree's root.
- * cat_db - A CategoryDatabase object.
- * max_depth - The limit beyond which no subcategories will be listed.
- This also guarantees that loops in the category structure
- won't be a problem.
- * filename - The textfile where the tree should be saved; None to print
- the tree to stdout.
+ This class generates a hierarchical overview of categories starting
+ from a given root category. The tree can be printed to stdout or
+ written to a file. Cycles in the category structure are prevented
+ by limiting the depth.
+
+ Example:
+ Create a tree view of ``Category:Physics`` up to 5 levels deep
+ and save it to ``physics_tree.txt``::
+
+ db = CategoryDatabase()
+ robot = CategoryTreeRobot(
+ 'Physics', db, 'physics_tree.txt', max_depth=5)
+
+ .. versionchanged:: 10.4
+ *max_depth* is keyword only.
+
+ :param cat_title: The category that serves as the root of the
+ tree.
+ :param cat_db: A :class:`CategoryDatabase` object
+ providing access to category data.
+ :param filename: Path to the text file where the tree
+ should be saved. If ``None``, the user will be prompted to enter
+ a filename. If an empty string is entered, the tree will be
+ printed to stdout. Relative paths are converted to absolute
+ paths using :meth:`config.datafilepath`.
+ :param max_depth: Maximum depth of subcategories to traverse.
+ Prevents infinite loops.
"""
def __init__(
self,
- cat_title,
- cat_db,
- filename=None,
+ cat_title: str,
+ cat_db: CategoryDatabase,
+ filename: str | None = None,
+ *,
max_depth: int = 10
) -> None:
"""Initializer."""
- self.cat_title = cat_title or \
- pywikibot.input(
+ self.cat_title = cat_title \
+ or pywikibot.input(
'For which category do you want to create a tree view?')
self.cat_db = cat_db
if filename is None:
filename = pywikibot.input(
'Please enter the name of the file '
'where the tree should be saved,\n'
- 'or press enter to simply show the tree:')
+ 'or press enter to simply show the tree:'
+ )
if filename and not os.path.isabs(filename):
filename = config.datafilepath(filename)
self.filename = filename
self.max_depth = max_depth
self.site = pywikibot.Site()
- def treeview(self, cat, current_depth: int = 0, parent=None) -> str:
- """Return a tree view of all subcategories of cat.
+ def treeview(self,
+ cat: pywikibot.Category,
+ current_depth: int = 0,
+ *,
+ parent: pywikibot.Category | None = None) -> str:
+ """Return a tree view of subcategories as a multi-line string.
- The multi-line string contains a tree view of all subcategories of cat,
- up to level max_depth. Recursively calls itself.
+ Generates a hierarchical tree view of all subcategories of the
+ given category *cat*, up to the depth specified by
+ ``self.max_depth``. This method is recursive.
- Parameters:
- * cat - the Category of the node we're currently opening.
- * current_depth - the current level in the tree (for recursion).
- * parent - the Category of the category we're coming from.
+ .. versionchanged:: 10.4
+ *parent* is keyword only.
+
+ Example:
+ To get a tree view of ``Category:Physics`` starting at depth 0::
+
+ cat = pywikibot.Category(site, 'Physics')
+ tree = robot.treeview(cat)
+
+ :param cat: The Category object currently being expanded in the
+ tree.
+ :param current_depth: Current depth level in the tree (used for
+ recursion).
+ :param parent: The parent Category from which we descended (to
+ avoid cycles).
+ :return: A multi-line string representing the tree structure,
+ including the number of pages in each category and links to
+ supercategories.
"""
result = '#' * current_depth
if current_depth > 0:
@@ -1680,7 +1729,7 @@
gen_factory.namespaces, summary)
elif action == 'tree':
bot = CategoryTreeRobot(options.get('from'), cat_db,
- options.get('to'), depth)
+ options.get('to'), max_depth=depth)
elif action == 'listify':
bot = CategoryListifyRobot(options.get('from'),
options.get('to'), summary,
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1183264?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: Ifd9dbdb9b5e4ac93341447311f4eecb981f8fe34
Gerrit-Change-Number: 1183264
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/+/1183258?usp=email )
Change subject: [10.5] Prepare next release
......................................................................
[10.5] Prepare next release
Change-Id: I1714a26f7335e8cac050a8325a1c48c82eb6ca64
---
M .pre-commit-config.yaml
M HISTORY.rst
M ROADMAP.rst
M pywikibot/__metadata__.py
M scripts/__init__.py
M scripts/pyproject.toml
6 files changed, 38 insertions(+), 31 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9bcdf70..abfaca0 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -65,7 +65,7 @@
language: python
require_serial: true
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.12.10
+ rev: v0.12.11
hooks:
- id: ruff-check
alias: ruff
diff --git a/HISTORY.rst b/HISTORY.rst
index 9a4b6dc..46ea471 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,6 +1,39 @@
Release History
===============
+10.4.0
+------
+*31 August 2025*
+
+* Apply client-side filtering for *maxsize* in misermode in
+ :meth:`Site.allpages()<pywikibot.site._generators.GeneratorsMixin.allpages>` (:phab:`T402995`)
+* Add :attr:`filter_func()<data.api.APIGeneratorBase.filter_func>` and :meth:`filter_item()
+ <data.api.APIGeneratorBase.filter_item>` filter function in :class:`APIGeneratorBase
+ <data.api.APIGeneratorBase>` and modify `generator` property to implement filtering in
+ `APIGeneratorBase` subclasses (:phab:`T402995`)
+* All parameters of :meth:`Site.allpages()<pywikibot.site._generators.GeneratorsMixin.allpages>`
+ except *start* must be given as keyword arguments.
+* Add support for bewwiktionary (:phab:`T402136`)
+* Add user-agent header to :mod:`eventstreams` requests (:phab:`T402796`)
+* Update i18n
+* Save global options in :attr:`bot.global_args` (:phab:`T250034`)
+* Update :mod:`plural` forms from unicode.org (:phab:`T114978`)
+* Add :class:`textlib.SectionList` to hold :attr:`textlib.Content.sections` (:phab:`T401464`)
+* :class:`pywikibot.Coordinate` parameters are keyword only
+* Add *strict* parameter to :meth:`Site.unconnected_pages()
+ <pywikibot.site._extensions.unconnected_pages>` and :func:`pagegenerators.UnconnectedPageGenerator`
+ (:phab:`T401699`)
+* Raise ValueError if a VAR_POSITIONAL parameter like *\*args* is used with
+ :class:`tools.deprecate_positionals` decorator
+* Add :meth:`get_value_at_timestamp()<pywikibot.ItemPage.get_value_at_timestamp>` API
+ to :class:`pywikibot.ItemPage` (:phab:`T400612`)
+* Clean up :mod:`setup` module (:phab:`T396356`)
+* Implement :meth:`pywikibot.ItemPage.get_best_claim` (:phab:`T400610`)
+* Add *expiry* parameter to :meth:`BasePage.watch()<page.BasePage.watch>` and
+ :meth:`Site.watch()<pywikibot.site._apisite.APISite.watch>`; fix the methods to return False if
+ page is missing and no expiry is set (:phab:`T330839`)
+
+
10.3.2
------
*12 August 2025*
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 50ff705..b959475 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,33 +1,7 @@
Current Release Changes
=======================
-* Apply client-side filtering for *maxsize* in misermode in
- :meth:`Site.allpages()<pywikibot.site._generators.GeneratorsMixin.allpages>` (:phab:`T402995`)
-* Add :attr:`filter_func()<data.api.APIGeneratorBase.filter_func>` and :meth:`filter_item()
- <data.api.APIGeneratorBase.filter_item>` filter function in :class:`APIGeneratorBase
- <data.api.APIGeneratorBase>` and modify `generator` property to implement filtering in
- `APIGeneratorBase` subclasses (:phab:`T402995`)
-* All parameters of :meth:`Site.allpages()<pywikibot.site._generators.GeneratorsMixin.allpages>`
- except *start* must be given as keyword arguments.
-* Add support for bewwiktionary (:phab:`T402136`)
-* Add user-agent header to :mod:`eventstreams` requests (:phab:`T402796`)
-* Update i18n
-* Save global options in :attr:`bot.global_args` (:phab:`T250034`)
-* Update :mod:`plural` forms from unicode.org (:phab:`T114978`)
-* Add :class:`textlib.SectionList` to hold :attr:`textlib.Content.sections` (:phab:`T401464`)
-* :class:`pywikibot.Coordinate` parameters are keyword only
-* Add *strict* parameter to :meth:`Site.unconnected_pages()
- <pywikibot.site._extensions.unconnected_pages>` and :func:`pagegenerators.UnconnectedPageGenerator`
- (:phab:`T401699`)
-* Raise ValueError if a VAR_POSITIONAL parameter like *\*args* is used with
- :class:`tools.deprecate_positionals` decorator
-* Add :meth:`get_value_at_timestamp()<pywikibot.ItemPage.get_value_at_timestamp>` API
- to :class:`pywikibot.ItemPage` (:phab:`T400612`)
-* Clean up :mod:`setup` module (:phab:`T396356`)
-* Implement :meth:`pywikibot.ItemPage.get_best_claim` (:phab:`T400610`)
-* Add *expiry* parameter to :meth:`BasePage.watch()<page.BasePage.watch>` and
- :meth:`Site.watch()<pywikibot.site._apisite.APISite.watch>`; fix the methods to return False if
- page is missing and no expiry is set (:phab:`T330839`)
+* (no changes yet)
Deprecations
diff --git a/pywikibot/__metadata__.py b/pywikibot/__metadata__.py
index 8481806..f278904 100644
--- a/pywikibot/__metadata__.py
+++ b/pywikibot/__metadata__.py
@@ -12,6 +12,6 @@
from time import strftime
-__version__ = '10.4.0'
+__version__ = '10.5.0.dev0'
__url__ = 'https://www.mediawiki.org/wiki/Manual:Pywikibot'
__copyright__ = f'2003-{strftime("%Y")}, Pywikibot team'
diff --git a/scripts/__init__.py b/scripts/__init__.py
index e42926f..f941522 100644
--- a/scripts/__init__.py
+++ b/scripts/__init__.py
@@ -34,7 +34,7 @@
from pathlib import Path
-__version__ = '10.4.0'
+__version__ = '10.5.0'
#: defines the entry point for pywikibot-scripts package
base_dir = Path(__file__).parent
diff --git a/scripts/pyproject.toml b/scripts/pyproject.toml
index 538369b..0886321 100644
--- a/scripts/pyproject.toml
+++ b/scripts/pyproject.toml
@@ -7,7 +7,7 @@
[project]
name = "pywikibot-scripts"
-version = "10.4.0"
+version = "10.5.0"
authors = [
{name = "xqt", email = "info(a)gno.de"},
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1183258?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: I1714a26f7335e8cac050a8325a1c48c82eb6ca64
Gerrit-Change-Number: 1183258
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/+/1183224?usp=email )
Change subject: tests: skip TestInterwikiLinksToNonLocalSites on Github
......................................................................
tests: skip TestInterwikiLinksToNonLocalSites on Github
Skip interwiki_link_tests.TestInterwikiLinksToNonLocalSites on Github
due to network access being blocked on translatewiki.net
(hopefully temporary).
Tests are still running on Jenkins CI.
Bug: T403292
Change-Id: I510046cdd25002654143811cdf9e515ba1835843
---
M tests/interwiki_link_tests.py
1 file changed, 4 insertions(+), 1 deletion(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/tests/interwiki_link_tests.py b/tests/interwiki_link_tests.py
index 6df9dbc..f3e83bf 100755
--- a/tests/interwiki_link_tests.py
+++ b/tests/interwiki_link_tests.py
@@ -1,12 +1,13 @@
#!/usr/bin/env python3
"""Test Interwiki Link functionality."""
#
-# (C) Pywikibot team, 2014-2022
+# (C) Pywikibot team, 2014-2025
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations
+import os
from contextlib import suppress
from pywikibot import config
@@ -45,6 +46,8 @@
self.assertEqual(link.namespace, 1)
+(a)unittest.skipIf(os.environ.get('GITHUB_ACTIONS'),
+ 'Tests blocked on twn, see T403292')
class TestInterwikiLinksToNonLocalSites(TestCase):
"""Tests for interwiki links to non local sites."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1183224?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: I510046cdd25002654143811cdf9e515ba1835843
Gerrit-Change-Number: 1183224
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1183214?usp=email )
Change subject: Doc: update ROADMAP.rst, CHANGELOG.rst and AUTHORS.rst
......................................................................
Doc: update ROADMAP.rst, CHANGELOG.rst and AUTHORS.rst
Change-Id: I8da2d14974819b66d2eb4f789cdb189c0440fc86
---
M AUTHORS.rst
M ROADMAP.rst
M scripts/CHANGELOG.rst
3 files changed, 34 insertions(+), 3 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/AUTHORS.rst b/AUTHORS.rst
index 3e29b4e..fa3bf8b 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -191,6 +191,7 @@
::
+ Lars G
Legoktm
Leonardo Gregianin
Lewis Cawte
@@ -381,7 +382,6 @@
Yrithinnd
Yuri Astrakhan
Yusuke Matsubara
- Zaher Kadour
Z
-
@@ -389,5 +389,7 @@
::
+ Zabe
+ Zaher Kadour
zhuyifei1999
Zoran Dori
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 059e3be..50ff705 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,9 +1,29 @@
Current Release Changes
=======================
+* Apply client-side filtering for *maxsize* in misermode in
+ :meth:`Site.allpages()<pywikibot.site._generators.GeneratorsMixin.allpages>` (:phab:`T402995`)
+* Add :attr:`filter_func()<data.api.APIGeneratorBase.filter_func>` and :meth:`filter_item()
+ <data.api.APIGeneratorBase.filter_item>` filter function in :class:`APIGeneratorBase
+ <data.api.APIGeneratorBase>` and modify `generator` property to implement filtering in
+ `APIGeneratorBase` subclasses (:phab:`T402995`)
+* All parameters of :meth:`Site.allpages()<pywikibot.site._generators.GeneratorsMixin.allpages>`
+ except *start* must be given as keyword arguments.
+* Add support for bewwiktionary (:phab:`T402136`)
+* Add user-agent header to :mod:`eventstreams` requests (:phab:`T402796`)
+* Update i18n
+* Save global options in :attr:`bot.global_args` (:phab:`T250034`)
+* Update :mod:`plural` forms from unicode.org (:phab:`T114978`)
+* Add :class:`textlib.SectionList` to hold :attr:`textlib.Content.sections` (:phab:`T401464`)
+* :class:`pywikibot.Coordinate` parameters are keyword only
+* Add *strict* parameter to :meth:`Site.unconnected_pages()
+ <pywikibot.site._extensions.unconnected_pages>` and :func:`pagegenerators.UnconnectedPageGenerator`
+ (:phab:`T401699`)
+* Raise ValueError if a VAR_POSITIONAL parameter like *\*args* is used with
+ :class:`tools.deprecate_positionals` decorator
* Add :meth:`get_value_at_timestamp()<pywikibot.ItemPage.get_value_at_timestamp>` API
- to :class:`pywikibot.ItemPage` (:phab:`T400612`)
-* Cleanup :mod:`setup` module (:phab:`T396356`)
+ to :class:`pywikibot.ItemPage` (:phab:`T400612`)
+* Clean up :mod:`setup` module (:phab:`T396356`)
* Implement :meth:`pywikibot.ItemPage.get_best_claim` (:phab:`T400610`)
* Add *expiry* parameter to :meth:`BasePage.watch()<page.BasePage.watch>` and
:meth:`Site.watch()<pywikibot.site._apisite.APISite.watch>`; fix the methods to return False if
@@ -16,6 +36,10 @@
Pending removal in Pywikibot 13
-------------------------------
+* 10.4.0: Require all parameters of :meth:`Site.allpages()
+ <pywikibot.site._generators.GeneratorsMixin.allpages>` except *start* to be keyword arguments.
+* 10.4.0: Positional arguments of :class:`pywikibot.Coordinate` are deprecated and must be given as
+ keyword arguments.
* 10.3.0: :meth:`throttle.Throttle.getDelay` and :meth:`throttle.Throttle.setDelays` were renamed to
:meth:`get_delay()<throttle.Throttle.get_delay>` and :meth:`set_delays()
<throttle.Throttle.set_delays>`; the old methods will be removed (:phab:`T289318`)
diff --git a/scripts/CHANGELOG.rst b/scripts/CHANGELOG.rst
index 4c90f44..b4e4da6 100644
--- a/scripts/CHANGELOG.rst
+++ b/scripts/CHANGELOG.rst
@@ -4,6 +4,11 @@
10.4.0
------
+addwikis
+^^^^^^^^
+
+* Add help options for addwikis script whereas `help` is deprecated.
+
interwiki
^^^^^^^^^
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1183214?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: I8da2d14974819b66d2eb4f789cdb189c0440fc86
Gerrit-Change-Number: 1183214
Gerrit-PatchSet: 3
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/+/1183215?usp=email )
Change subject: Request: use unittest_print to show Exception in Rweusests._http_request
......................................................................
Request: use unittest_print to show Exception in Rweusests._http_request
Bug: T403292
Change-Id: I26f555eb074a0452a16fc0952c0e071792b3f0d8
---
M pywikibot/data/api/_requests.py
1 file changed, 11 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py
index 0186acc..07fa07f 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -49,6 +49,8 @@
if TEST_RUNNING:
import unittest
+ # lazy load unittest_print to prevent circular imports
+
# Actions that imply database updates on the server, used for various
# things like throttling or skipping actions when we're in simulation
# mode
@@ -716,8 +718,15 @@
# 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}')
+ tb = traceback.format_exc()
+ msg = f'{uri}, {paramstring}'
+ if TEST_RUNNING:
+ from tests import unittest_print
+ unittest_print(tb)
+ unittest_print(msg)
+ else:
+ pywikibot.error(tb)
+ pywikibot.log(msg)
else:
return response, use_get
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1183215?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: I26f555eb074a0452a16fc0952c0e071792b3f0d8
Gerrit-Change-Number: 1183215
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot