jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
refactor options

replace old_cat_title and new_cat_title with options['from'] and options['to']

Change-Id: I3b60a5d108065f1c9ba01df57e3b7bd46023afc8
---
M scripts/category.py
1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/scripts/category.py b/scripts/category.py
index 8d37641..e5addb1 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -1363,9 +1363,10 @@
'recurse': False
}

- def __init__(self, cat: Optional[str], **kwargs) -> None:
+ def __init__(self, **kwargs) -> None:
"""Initializer."""
site = pywikibot.Site()
+ cat = kwargs.pop('from', None)
if not cat:
cat = pywikibot.input(
'Please enter the name of the category to clean:')
@@ -1426,8 +1427,7 @@
:param args: command line arguments.
"""
options = {}
- old_cat_title = None
- new_cat_title = None
+ # TODO: use options instead following variables:
batch = False
summary = ''
inplace = False
@@ -1477,10 +1477,8 @@
sort_by_last_name = True
elif option == 'rebuild':
rebuild = True
- elif option == 'from':
- old_cat_title = value.replace('_', ' ')
- elif option == 'to':
- new_cat_title = value.replace('_', ' ')
+ elif option in ('from', 'to'):
+ options[option] = value.replace('_', ' ')
elif option == 'batch':
batch = True
elif option == 'inplace':
@@ -1547,16 +1545,17 @@
# pages from the wiki simultaneously.
gen = pagegenerators.PreloadingGenerator(gen)
bot = CategoryAddBot(gen,
- newcat=new_cat_title,
+ newcat=options.get('to'),
sort_by_last_name=sort_by_last_name,
create=create_pages,
comment=summary,
follow_redirects=follow_redirects)
elif action == 'remove':
- if not old_cat_title:
- old_cat_title = pywikibot.input('Please enter the name of the '
- 'category that should be removed:')
- bot = CategoryMoveRobot(oldcat=old_cat_title,
+ if 'from' not in options:
+ options['from'] = \
+ pywikibot.input('Please enter the name of the '
+ 'category that should be removed:')
+ bot = CategoryMoveRobot(oldcat=options.get('from'),
batch=batch,
comment=summary,
inplace=inplace,
@@ -1566,19 +1565,19 @@
pagesonly=pagesonly,
deletion_comment=use_deletion_summary)
elif action == 'move':
- if not old_cat_title:
- old_cat_title = pywikibot.input(
+ if 'from' not in options:
+ options['from'] = pywikibot.input(
'Please enter the old name of the category:')
- if not new_cat_title:
- new_cat_title = pywikibot.input(
+ if 'to' not in options:
+ options['to'] = pywikibot.input(
'Please enter the new name of the category:')
if use_deletion_summary:
deletion_comment = \
CategoryMoveRobot.DELETION_COMMENT_SAME_AS_EDIT_COMMENT
else:
deletion_comment = CategoryMoveRobot.DELETION_COMMENT_AUTOMATIC
- bot = CategoryMoveRobot(oldcat=old_cat_title,
- newcat=new_cat_title,
+ bot = CategoryMoveRobot(oldcat=options.get('from'),
+ newcat=options.get('to'),
batch=batch,
comment=summary,
inplace=inplace,
@@ -1592,19 +1591,21 @@
move_together=move_together,
keep_sortkey=keep_sortkey)
elif action == 'tidy':
- bot = CategoryTidyRobot(old_cat_title, cat_db, gen_factory.namespaces,
- summary)
+ bot = CategoryTidyRobot(options.get('from'), cat_db,
+ gen_factory.namespaces, summary)
elif action == 'tree':
- bot = CategoryTreeRobot(old_cat_title, cat_db, new_cat_title, depth)
+ bot = CategoryTreeRobot(options.get('from'), cat_db,
+ options.get('to'), depth)
elif action == 'listify':
- bot = CategoryListifyRobot(old_cat_title, new_cat_title, summary,
+ bot = CategoryListifyRobot(options.get('from'),
+ options.get('to'), summary,
append, overwrite, showimages,
talk_pages=talkpages,
recurse=options.get('recurse', False),
prefix=prefix,
namespaces=gen_factory.namespaces)
elif action == 'clean':
- bot = CleanBot(old_cat_title, **options)
+ bot = CleanBot(**options)

if not suggest_help(missing_action=not action):
pywikibot.Site().login()

To view, visit change 759204. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I3b60a5d108065f1c9ba01df57e3b7bd46023afc8
Gerrit-Change-Number: 759204
Gerrit-PatchSet: 4
Gerrit-Owner: Costa Shul <constantine.shulyupin@gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged