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

Change subject: [FEAT] imageuncat: Use configured site
......................................................................


[FEAT] imageuncat: Use configured site

Instead of always using the image repository it uses the configured site. There
is no need to only run it on the site's image repository. This changes how the
script works as now the commons site must be specifically given but it warns
beforehand.

Change-Id: I69531cd3a3115f45c9b9dafbb6f5c41b6ed40e40
---
M scripts/imageuncat.py
1 file changed, 32 insertions(+), 3 deletions(-)

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



diff --git a/scripts/imageuncat.py b/scripts/imageuncat.py
index e553851..d543730 100755
--- a/scripts/imageuncat.py
+++ b/scripts/imageuncat.py
@@ -5,10 +5,20 @@
 
 See imagerecat.py (still working on that one) to add these images to 
categories.
 
+This script is working on the given site, so if the commons should be handled,
+the site commons should be given and not a Wikipedia or similar.
+
+-yesterday        Go through all uploads from yesterday.
+
+-recentchanges    Go through the changes made between 120 minutes and 70
+                  minutes ago. (This overrides the '-recentchanges' default
+                  generator)
+
+&params;
 """
 #
 # (C) Multichill, 2008
-# (C) Pywikibot team, 2009-2014
+# (C) Pywikibot team, 2009-2015
 #
 # Distributed under the terms of the MIT license.
 #
@@ -21,6 +31,10 @@
 
 import pywikibot
 from pywikibot import pagegenerators
+
+docuReplacements = {
+    '&params;': pagegenerators.parameterHelp,
+}
 
 # Probably unneeded because these are hidden categories. Have to figure it out.
 ignoreCategories = [u'[[Category:CC-BY-SA-3.0]]',
@@ -1333,8 +1347,23 @@
 
     local_args = pywikibot.handle_args(args)
 
-    # use the default imagerepository normally commons
-    site = pywikibot.Site().image_repository()
+    site = pywikibot.Site()
+
+    if site.code != 'commons' or site.family.name != 'commons':
+        pywikibot.warning('This script is primarily written for Wikimedia '
+                          'Commons, but has been invoked with site {0}. It '
+                          'might work for other sites but there is no '
+                          'guarantee that it does the right 
thing.'.format(site))
+        choice = pywikibot.input_choice(
+            'How do you want to continue?',
+            (('Continue using {0}'.format(site), 'c'),
+             ('Switch to Wikimedia Commons', 's'),
+             ('Quit', 'q')),
+            automatic_quit=False)
+        if choice == 's':
+            site = pywikibot.Site('commons', 'commons')
+        elif choice == 'q':
+            return False
 
     genFactory = pagegenerators.GeneratorFactory(site)
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I69531cd3a3115f45c9b9dafbb6f5c41b6ed40e40
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to