jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/791774 )
Change subject: [bugfix] Preload pages if GeneratorFactory.articlenotfilter_list is not
empty
......................................................................
[bugfix] Preload pages if GeneratorFactory.articlenotfilter_list is not empty
- If pagegenerators.GeneratorFactory.articlenotfilter_list is not empty
Page objects should be preloaded like for articlefilter_list.
- Add a new instance variable is_preloading which is set to True or False
when GeneratorFactory.getCombinedGenerator() is called. Otherwise its
value is None.
Change-Id: Icb2b62fb2fcbd6be0012a217b124242f0c4edd98
---
M pywikibot/pagegenerators.py
1 file changed, 24 insertions(+), 3 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 002ca17..bd1374a 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -468,8 +468,8 @@
This factory is responsible for processing command line arguments
that are used by many scripts and that determine which pages to work on.
- :Note: GeneratorFactory must be instantiated after global arguments are
- parsed except if site parameter is given.
+ .. note:: GeneratorFactory must be instantiated after global
+ arguments are parsed except if site parameter is given.
"""
def __init__(self, site: OPT_SITE_TYPE = None,
@@ -505,6 +505,21 @@
self.nopreload = False
self._validate_options(enabled_options, disabled_options)
+ self.is_preloading = None # type: Optional[bool]
+ """Return whether Page objects are preloaded. You may use this
+ instance variable after :meth:`getCombinedGenerator` is called
+ e.g.::
+
+ gen_factory = GeneratorFactory()
+ print(gen_factory.is_preloading) # None
+ gen = gen_factory.getCombinedGenerator()
+ print(gen_factory.is_preloading) # True or False
+
+ Otherwise the value is undefined and gives None.
+
+ .. versionadded:: 7.3
+ """
+
def _validate_options(self,
enable: Optional[Iterable[str]],
disable: Optional[Iterable[str]]) -> None:
@@ -574,6 +589,9 @@
Only call this after all arguments have been parsed.
+ .. versionchanged:: 7.3
+ set the instance variable :attr:`is_preloading` to True or False.
+
:param gen: Another generator to be combined with
:param preload: preload pages using PreloadingGenerator
unless self.nopreload is True
@@ -649,7 +667,10 @@
dupfiltergen = CategoryFilterPageGenerator(
dupfiltergen, self.catfilter_list)
- if (preload or self.articlefilter_list) and not self.nopreload:
+ self.is_preloading = not self.nopreload and bool(
+ preload or self.articlefilter_list or self.articlenotfilter_list)
+
+ if self.is_preloading:
if isinstance(dupfiltergen, DequeGenerator):
dupfiltergen = DequePreloadingGenerator(dupfiltergen)
else:
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/791774
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: Icb2b62fb2fcbd6be0012a217b124242f0c4edd98
Gerrit-Change-Number: 791774
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged