jenkins-bot submitted this change.
CategoryListifyRobot: refactor `prefix`
use options and kwargs, reduce number of function arguments to make
code more generic and clean
Change-Id: Ib067a6366a13dd29ad721105f5a4b7938ba9bd2e
---
M scripts/category.py
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/scripts/category.py b/scripts/category.py
index 6923a4a..9046ce2 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -982,8 +982,8 @@
show_images: bool = False, *,
talk_pages: bool = False,
recurse: Union[int, bool] = False,
- prefix: str = '*',
- namespaces=None) -> None:
+ namespaces=None,
+ **kwargs) -> None:
"""Initializer."""
self.edit_summary = edit_summary
self.append = append
@@ -1000,7 +1000,7 @@
self.list = pywikibot.Page(self.site, list_title)
self.talk_pages = talk_pages
self.recurse = recurse
- self.prefix = prefix
+ self.prefix = kwargs.pop('prefix', '*')
self.namespaces = self.site.namespaces.resolve(namespaces or [])
self.subcats = not self.namespaces or 'Category' in self.namespaces
@@ -1510,7 +1510,6 @@
move_together = False
keep_sortkey = None
depth = 5
- prefix = '*'
# Process global args and prepare generator args parser
local_args = pywikibot.handle_args(args)
@@ -1585,7 +1584,7 @@
elif option == 'keepsortkey':
keep_sortkey = True
elif option == 'prefix':
- prefix = value
+ options[option] = value
elif option == 'always':
options[option] = True
else:
@@ -1669,8 +1668,8 @@
append, overwrite, showimages,
talk_pages=talkpages,
recurse=options.get('recurse', False),
- prefix=prefix,
- namespaces=gen_factory.namespaces)
+ namespaces=gen_factory.namespaces,
+ **options)
elif action == 'clean':
bot = CleanBot(**options)
To view, visit change 873037. To unsubscribe, or for help writing mail filters, visit settings.