jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/853493 )
Change subject: [BUGFIX] re-enable running scripts in userscripts folder via pwb wrapper
......................................................................
[BUGFIX] re-enable running scripts in userscripts folder via pwb wrapper
With 935f332 change the scripts.userscripts path for scripts was lost
and pywikibot.scripts was used twice.
Bug: T322479
Change-Id: I2c440f1a84cf86dba42e14e2ae3955fc896fcad6
---
M pywikibot/scripts/wrapper.py
1 file changed, 6 insertions(+), 6 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/scripts/wrapper.py b/pywikibot/scripts/wrapper.py
index 4446ae8..d996f02 100755
--- a/pywikibot/scripts/wrapper.py
+++ b/pywikibot/scripts/wrapper.py
@@ -408,21 +408,21 @@
if found: # pragma: no cover
return found
- # search for system scripts in pywikibot.scripts directory
- found = test_paths([''], wrapper_dir)
- if found:
- return found
-
if not site_package:
script_paths = [
+ 'scripts.userscripts',
'scripts',
'scripts.maintenance',
- 'pywikibot.scripts',
]
found = test_paths(script_paths, wrapper_dir.parents[1])
if found:
return found
+ # search for system scripts in pywikibot.scripts directory
+ found = test_paths([''], wrapper_dir)
+ if found:
+ return found
+
return find_alternates(filename, path_list)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/853493
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2c440f1a84cf86dba42e14e2ae3955fc896fcad6
Gerrit-Change-Number: 853493
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/853266 )
Change subject: [sphinx] hide object path in Sphinx
......................................................................
[sphinx] hide object path in Sphinx
Change-Id: Ia51160b91b45c4291bc4105d772fe0fedfde0133
---
M docs/conf.py
M docs/requirements.txt
2 files changed, 3 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/conf.py b/docs/conf.py
index 40f4cfd..da8cdb2 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -43,7 +43,7 @@
# If your documentation needs a minimal Sphinx version, state it here.
#
-needs_sphinx = '5.1.1'
+needs_sphinx = '5.2.3'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@@ -367,6 +367,7 @@
autodoc_typehints = 'description'
# autosectionlabel_prefix_document = True
suppress_warnings = ['autosectionlabel.*']
+toc_object_entries_show_parents = 'hide'
# Allow lines like "Example:" to be followed by a code block
napoleon_use_admonition_for_examples = True
diff --git a/docs/requirements.txt b/docs/requirements.txt
index 53d9a1f..57f3cda 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,5 +1,5 @@
# This is a PIP requirements file for building Sphinx documentation of pywikibot
# requirements.txt is also needed
-sphinx >= 5.1.1
+sphinx >= 5.2.3
rstcheck >=3.5.0
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/853266
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ia51160b91b45c4291bc4105d772fe0fedfde0133
Gerrit-Change-Number: 853266
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/852123 )
Change subject: [FIX] Fix string concatenation in interwiki.py
......................................................................
[FIX] Fix string concatenation in interwiki.py
Bug: T322180
Change-Id: I53ae104a5aea14741385354469fa8c81eb88547c
---
M scripts/interwiki.py
1 file changed, 4 insertions(+), 4 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 551fb3d..c70e6ca 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -1293,7 +1293,7 @@
"""Return True if all the work for this subject has completed."""
return not self.todo
- def problem(self, txt, createneed: bool = True) -> None:
+ def problem(self, txt: str, createneed: bool = True) -> None:
"""Report a problem with the resolution of this subject."""
pywikibot.error(txt)
self.confirm = True
@@ -1328,7 +1328,7 @@
if site != self.origin.site:
new[site].append(page)
elif page != self.origin:
- self.problem('Found link to ' + page)
+ self.problem(f'Found link to {page}')
self.whereReport(page)
errorCount += 1
@@ -1336,7 +1336,7 @@
for site, pages in new.items():
if len(pages) > 1:
errorCount += 1
- self.problem('Found more than one link for ' + site)
+ self.problem(f'Found more than one link for {site}')
if not errorCount and not self.conf.select:
# no errors, so all lists have only one item
@@ -1359,7 +1359,7 @@
continue
pywikibot.info('=' * 30)
- pywikibot.info('Links to ' + site)
+ pywikibot.info(f'Links to {site}')
for i, page2 in enumerate(pages, 1):
pywikibot.info(f' ({i}) Found link to {page2} in:')
self.whereReport(page2, indent=8)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/852123
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I53ae104a5aea14741385354469fa8c81eb88547c
Gerrit-Change-Number: 852123
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck <alangiderick(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Prod <prodigion(a)hotmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/851686 )
Change subject: [fix] Fix UserWarning: Site objects have been created before arguments handled
......................................................................
[fix] Fix UserWarning: Site objects have been created before arguments handled
wrapper script was renamed from pwb.py to wrapper.py; the pwb.py script
is a caller script to invoke wrapper.py.
Change-Id: I9fd3a12c806a56206302b156f91fdbeef8198c00
---
M pywikibot/bot.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index d85f473..4a85b17 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1000,7 +1000,7 @@
except (UnknownFamilyError, UnknownSiteError):
pywikibot.exception(exc_info=False)
sys.exit(1)
- if calledModuleName() == 'pwb':
+ if calledModuleName() == 'wrapper':
pywikibot._sites.clear()
if username:
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/851686
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I9fd3a12c806a56206302b156f91fdbeef8198c00
Gerrit-Change-Number: 851686
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/843988 )
Change subject: [IMPR] Allow all Site.categorymembers() parameters for Category.subcategories()
......................................................................
[IMPR] Allow all Site.categorymembers() parameters for Category.subcategories()
- enable all parameters of Site.categorymembers() with
Category.subcategories() method
- drop cache because a lot of parameters are used now
- call Category.members() to implement Category.subcategories to prevent
code duplication
- update tests
Change-Id: Iad5570767cbe497e107d8b8f989bc50a7ef16560
---
M pywikibot/page/_category.py
M tests/category_tests.py
2 files changed, 30 insertions(+), 111 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/page/_category.py b/pywikibot/page/_category.py
index 173bf67..d6ea85f 100644
--- a/pywikibot/page/_category.py
+++ b/pywikibot/page/_category.py
@@ -58,25 +58,38 @@
title_with_sort_key += '|' + key
return f'[[{title_with_sort_key}]]'
- def subcategories(self,
+ def subcategories(self, *,
recurse: Union[int, bool] = False,
- total: Optional[int] = None,
- content: bool = False):
- """
- Iterate all subcategories of the current category.
+ **kwargs: Any) -> Iterable[Page]:
+ """Iterate all subcategories of the current category.
- :param recurse: if not False or 0, also iterate subcategories of
+ **Usage:**
+
+ >>> site = pywikibot.Site('wikipedia:en')
+ >>> cat = pywikibot.Category(site, 'Contents')
+ >>> next(cat.subcategories())
+ Category('Category:Wikipedia administration')
+ >>> len(list(cat.subcategories(recurse=2, total=50)))
+ 50
+
+ .. seealso:: :attr:`categoryinfo`
+
+ .. versionchanged:: 8.0
+ all parameters are keyword arguments only. Additional
+ parameters are supported.
+
+ :param recurse: if not False or 0, also iterate articles in
subcategories. If an int, limit recursion to this number of
- levels. (Example: recurse=1 will iterate direct subcats and
- first-level sub-sub-cats, but no deeper.)
- :param total: iterate no more than this number of
- subcategories in total (at all levels)
- :param content: if True, retrieve the content of the current version
- of each category description page (default False)
+ levels. (Example: ``recurse=1`` will iterate articles in
+ first-level subcats, but no deeper.)
+ :param kwargs: Additional parameters. Refer to
+ :meth:`APISite.categorymembers()
+ <pywikibot.site._generators.GeneratorsMixin.categorymembers>`
+ for complete list (*member_type* excluded).
"""
-
- def is_cache_valid(cache: dict, content: bool) -> bool:
- return cache['content'] or not content
+ if kwargs.pop('member_type', False):
+ raise TypeError('subcategories() got an unexpected keyword '
+ "argument 'member_type'")
if not self.categoryinfo['subcats']:
return
@@ -84,50 +97,8 @@
if not isinstance(recurse, bool) and recurse:
recurse -= 1
- if (not hasattr(self, '_subcats')
- or not is_cache_valid(self._subcats, content)):
- cache = {'data': [], 'content': content}
-
- for subcat in self.site.categorymembers(
- self, member_type='subcat', total=total, content=content):
- cache['data'].append(subcat)
- yield subcat
- if total is not None:
- total -= 1
- if total == 0:
- return
-
- if recurse:
- for item in subcat.subcategories(
- recurse, total=total, content=content):
- yield item
- if total is None:
- continue
-
- total -= 1
- if total == 0:
- return
-
- # cache is valid only if all subcategories are fetched (T88217)
- self._subcats = cache
- else:
- for subcat in self._subcats['data']:
- yield subcat
- if total is not None:
- total -= 1
- if total == 0:
- return
-
- if recurse:
- for item in subcat.subcategories(
- recurse, total=total, content=content):
- yield item
- if total is None:
- continue
-
- total -= 1
- if total == 0:
- return
+ yield from self.members(member_type='subcat', recurse=recurse,
+ **kwargs)
def articles(self, *,
recurse: Union[int, bool] = False,
diff --git a/tests/category_tests.py b/tests/category_tests.py
index 3bd8f1f..862ed62 100755
--- a/tests/category_tests.py
+++ b/tests/category_tests.py
@@ -107,58 +107,6 @@
subcategories_total = list(cat.subcategories(total=2))
self.assertLength(subcategories_total, 2)
- def test_subcategories_cache_length(self):
- """Test the subcategories cache length."""
- site = self.get_site()
-
- # test cache is valid only if all members of cat are iterated.
- cat = pywikibot.Category(site, 'Category:Wikipedians by gender')
- subcategories = list(cat.subcategories(total=2))
- self.assertLength(subcategories, 2)
- self.assertFalse(hasattr(cat, '_subcats'))
-
- subcategories = list(cat.subcategories())
- self.assertGreater(len(subcategories), 2)
- self.assertTrue(hasattr(cat, '_subcats'))
-
- # new cat, no cached data.
- cat = pywikibot.Category(site, 'Category:Wikipedians by gender')
-
- # cache not available yet due to partial iteration.
- gen = cat.subcategories()
- _ = next(gen)
- self.assertFalse(hasattr(cat, '_subcats'))
-
- # cache available.
- _ = list(gen)
- self.assertTrue(hasattr(cat, '_subcats'))
-
- def test_subcategories_cache_content(self):
- """Test the subcategories cache content."""
- site = self.get_site()
- cat = pywikibot.Category(site, 'Category:Wikipedians by gender')
-
- subcategories = list(cat.subcategories(content=False))
- cache_id_1 = id(cat._subcats)
- cache_len_1 = len(subcategories)
- subcat = subcategories[0]
- self.assertFalse(subcat.has_content())
-
- # toggle content.
- subcategories = list(cat.subcategories(content=True))
- cache_len_2 = len(subcategories)
- cache_id_2 = id(cat._subcats)
- subcat = subcategories[0]
- self.assertTrue(subcat.has_content())
- # cache reloaded.
- self.assertNotEqual(cache_id_1, cache_id_2)
- self.assertTrue(cache_len_1, cache_len_2)
-
- # cache not reloaded.
- _ = list(cat.subcategories(content=True))
- cache_id_3 = id(cat._subcats)
- self.assertEqual(cache_id_2, cache_id_3)
-
def test_subcategories_recurse(self):
"""Test the subcategories method with recurse=True."""
site = self.get_site()
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/843988
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Iad5570767cbe497e107d8b8f989bc50a7ef16560
Gerrit-Change-Number: 843988
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged