jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/805891 )

Change subject: [IMPR] Add -confirm option to harvest_template.py
......................................................................

[IMPR] Add -confirm option to harvest_template.py

- add -confirm option which sets 'always' option to False
- remove -always option because it is the default behavior
- update argument parsing

Bug: T310356
Change-Id: Ided3e3288bb32b9514ce6373ced8bc4b4b104188
---
M scripts/harvest_template.py
1 file changed, 10 insertions(+), 11 deletions(-)

Approvals:
  Matěj Suchánek: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index 04cd5df..38d58f9 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -22,8 +22,7 @@

 You can also use additional parameters:

--always             If used, the bot won't ask if it should add the specified
-                    text
+-confirm            If used, the bot will ask if it should make changes

 -create             Create missing items before importing.

@@ -375,26 +374,26 @@
     fields = {}
     options = {}
     for arg in local_args:
-        if arg.startswith('-template'):
-            if len(arg) == 9:
-                template_title = pywikibot.input(
-                    'Please enter the template to work on:')
-            else:
-                template_title = arg[10:]
+        opt, _, value = arg.partition(':')
+        if opt == '-template':
+            template_title = value or pywikibot.input(
+                'Please enter the template to work on:')
+        elif opt == '-confirm':
+            options['always'] = False
         elif arg.startswith('-create'):
             options['create'] = True
         elif gen.handle_arg(arg):
             if arg.startswith('-transcludes:'):
-                template_title = arg[13:]
+                template_title = value
         else:
-            optional = arg.startswith('-')
+            optional = opt.startswith('-')
             complete = len(current_args) == 3
             if optional:
                 needs_second = len(current_args) == 1
                 if needs_second:
                     break  # will stop below

-                arg, _, value = arg[1:].partition(':')
+                arg = opt[1:]
                 if len(current_args) == 0:
                     assert not fields
                     options[arg] = value or True

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/805891
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: Ided3e3288bb32b9514ce6373ced8bc4b4b104188
Gerrit-Change-Number: 805891
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: JAn Dudík <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to