jenkins-bot has submitted this change and it was merged.

Change subject: Use unprotect i18n messages
......................................................................


Use unprotect i18n messages

When -unprotect flag is set or when the default value
for protection is 'all', use the unprotect i18n messages
when applicable for edit summary.
Fix generator_type extraction by removing colon from name

Bug: T63312
Change-Id: I2cda1fdd472070e4fd65392df9db2d0eebea41ba
---
M scripts/protect.py
1 file changed, 17 insertions(+), 10 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/protect.py b/scripts/protect.py
index 18b6a6c..2bfaade 100644
--- a/scripts/protect.py
+++ b/scripts/protect.py
@@ -161,6 +161,7 @@
     genFactory = pagegenerators.GeneratorFactory()
     site = pywikibot.Site()
 
+    generator_type = None
     protection_levels = set(site.protection_levels())
     protection_types = site.protection_types()
     if '' in protection_levels:
@@ -182,7 +183,7 @@
             default_level = 'all'
         elif arg.startswith('-default'):
             if len(arg) == len('-default'):
-                default_level = None
+                default_level = 'sysop'
             else:
                 default_level = arg[len('-default:'):]
         else:
@@ -198,19 +199,25 @@
             if not is_p_type:
                 if not genFactory.handleArg(arg):
                     raise ValueError('Unknown parameter "{0}"'.format(arg))
-                found = arg.find(':') + 1
+                found = arg.find(':')
                 if found:
-                    message_properties.update({'cat': arg[found:],
-                                               'page': arg[found:]})
+                    message_properties.update({'cat': arg[found + 1:],
+                                               'page': arg[found + 1:]})
 
                 if 'summary' not in options:
                     generator_type = arg[1:found] if found > 0 else arg[1:]
-                    if generator_type in default_summaries:
-                        message_type = default_summaries[generator_type]
-                        if message_type == 'simple' or message_properties:
-                            options['summary'] = i18n.twtranslate(
-                                site, 'protect-{0}'.format(message_type),
-                                message_properties)
+
+    if generator_type in default_summaries:
+        message_type = default_summaries[generator_type]
+        if message_type == 'simple' or message_properties:
+            if default_level == 'all':
+                options['summary'] = i18n.twtranslate(
+                    site, 'unprotect-{0}'.format(message_type),
+                    message_properties)
+            else:
+                options['summary'] = i18n.twtranslate(
+                    site, 'protect-{0}'.format(message_type),
+                    message_properties)
 
     generator = genFactory.getCombinedGenerator()
     # We are just protecting pages, so we have no need of using a preloading

-- 
To view, visit https://gerrit.wikimedia.org/r/185784
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2cda1fdd472070e4fd65392df9db2d0eebea41ba
Gerrit-PatchSet: 9
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Sn1per <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to