Skip to content

Commit

Permalink
[bugfix] ensure that -from and -to arguments are not equal
Browse files Browse the repository at this point in the history
verify that -from and -to arguments are not equal for move action.
otherwise ask for new values. If the given answer for -from is empty,
leave the script.

Bug: T384753
Change-Id: Ib23dba9d8e69571b272ce460312c7ca79baa3922
  • Loading branch information
xqt committed Feb 25, 2025
1 parent 71e05c8 commit 12c1c5c
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions scripts/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
:mod:`pagegenerators` are supported with "move" and "remove" action.
"""
#
# (C) Pywikibot team, 2004-2024
# (C) Pywikibot team, 2004-2025
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -1638,12 +1638,24 @@ def main(*args: str) -> None:
deletion_comment=use_deletion_summary,
generator=gen)
elif action == 'move':
if 'from' not in options:
options['from'] = pywikibot.input(
'Please enter the old name of the category:')
if 'to' not in options:
options['to'] = pywikibot.input(
'Please enter the new name of the category:')
while True:
if 'from' not in options:
options['from'] = pywikibot.input(
'Please enter the old name of the category:')
if not options['from']:
return

if 'to' not in options:
options['to'] = pywikibot.input(
'Please enter the new name of the category:')

if options['from'] != options['to']:
break

pywikibot.error('-from and -to arguments are equal, please retry.')
del options['from']
del options['to']

if use_deletion_summary:
deletion_comment = \
CategoryMoveRobot.DELETION_COMMENT_SAME_AS_EDIT_COMMENT
Expand Down

0 comments on commit 12c1c5c

Please sign in to comment.