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

Change subject: spamremove.py: Provide -summary and -protocol options
......................................................................


spamremove.py: Provide -summary and -protocol options

Allow users to override the default protocol prefix and summary.

Bug: T57021
Change-Id: I589b2f16d9ef5a5e16118c9a3bbca868c5721bf0
---
M scripts/spamremove.py
1 file changed, 18 insertions(+), 4 deletions(-)

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



diff --git a/scripts/spamremove.py b/scripts/spamremove.py
index 246e5c1..57ae751 100755
--- a/scripts/spamremove.py
+++ b/scripts/spamremove.py
@@ -20,10 +20,12 @@
 
 -namespace:       Filters the search to a given namespace. If this is specified
                   multiple times it will search all given namespaces
+-protocol:        The protocol prefix (default: "http")
+-summary:         A string to be used instead of the default summary
 
 """
 #
-# (C) Pywikibot team, 2007-2015
+# (C) Pywikibot team, 2007-2016
 #
 # Distributed under the terms of the MIT license.
 #
@@ -53,6 +55,8 @@
     always = False
     namespaces = []
     spamSite = ''
+    protocol = 'http'
+    summary = None
     for arg in pywikibot.handle_args(args):
         if arg == "-always":
             always = True
@@ -61,6 +65,10 @@
                 namespaces.append(int(arg[len('-namespace:'):]))
             except ValueError:
                 namespaces.append(arg[len('-namespace:'):])
+        elif arg.startswith('-protocol:'):
+            protocol = arg.partition(':')[2]
+        elif arg.startswith('-summary:'):
+            summary = arg.partition(':')[2]
         else:
             spamSite = arg
 
@@ -69,10 +77,16 @@
         return False
 
     mysite = pywikibot.Site()
-    pages = mysite.exturlusage(spamSite, namespaces=namespaces, content=True)
+    pages = mysite.exturlusage(
+        spamSite, protocol=protocol, namespaces=namespaces, content=True
+    )
 
-    summary = i18n.twtranslate(mysite, 'spamremove-remove',
-                               {'url': spamSite})
+    if not summary:
+        summary = i18n.twtranslate(
+            mysite,
+            'spamremove-remove',
+            {'url': spamSite}
+        )
     for i, p in enumerate(pages, 1):
         text = p.text
         if spamSite not in text:

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I589b2f16d9ef5a5e16118c9a3bbca868c5721bf0
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.w...@gmail.com>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
Pywikibot-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to