jenkins-bot submitted this change.

View Change

Approvals: Matěj Suchánek: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
[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(-)

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 change 791774. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Icb2b62fb2fcbd6be0012a217b124242f0c4edd98
Gerrit-Change-Number: 791774
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged