[Pywikipedia-l] SVN: [5344] trunk/pywikipedia/nowcommons.py

siebrand at svn.wikimedia.org siebrand at svn.wikimedia.org
Fri May 9 17:08:13 UTC 2008


Revision: 5344
Author:   siebrand
Date:     2008-05-09 17:08:13 +0000 (Fri, 09 May 2008)

Log Message:
-----------
Add switch -replaceonly when working on a wiki without sysop rights

Modified Paths:
--------------
    trunk/pywikipedia/nowcommons.py

Modified: trunk/pywikipedia/nowcommons.py
===================================================================
--- trunk/pywikipedia/nowcommons.py	2008-05-09 16:32:01 UTC (rev 5343)
+++ trunk/pywikipedia/nowcommons.py	2008-05-09 17:08:13 UTC (rev 5344)
@@ -9,8 +9,8 @@
 the source wiki. If multiple versions of the file exist, the script will not
 delete. If the MD5 comparison is not equal, the script will not delete.
 
-A sysop account on the local wiki is required if you want this script to work
-properly.
+A sysop account on the local wiki is required if you want all features of
+this script to work properly.
 
 This script understands various command-line arguments:
     -autonomous:    run automatically, do not ask any questions. All files
@@ -30,6 +30,9 @@
                     or in galleries.  However, it can also make more
                     mistakes.
 
+    -replaceonly:   Use this if you do not have a local sysop account, but do
+                    wish to replace links from the NowCommons template.
+
 Known issues. Please fix these if you are capable and motivated:
 - if a file marked nowcommons is not present on Wikimedia Commons, the bot
   will exit.
@@ -53,6 +56,7 @@
 replace = False
 replacealways = False
 replaceloose = False
+replaceonly = False
 
 for arg in wikipedia.handleArgs():
     if arg == '-autonomous':
@@ -64,6 +68,8 @@
         replacealways = True
     if arg == '-replaceloose':
         replaceloose = True
+    if arg == '-replaceonly':
+        replaceonly = True
 
 nowCommons = {
     '_default': [
@@ -193,20 +199,21 @@
                     else:
                         wikipedia.output(u'No page is using \"\03{lightgreen}%s\03{default}\" anymore.' % localImagePage.titleWithoutNamespace())
                 commonsText = commonsImagePage.get()
-                if md5 == commonsImagePage.getFileMd5Sum():
-                    wikipedia.output(u'The image is identical to the one on Commons.')
-                    if autonomous == False:
-                        wikipedia.output(u'\n\n>>>> Description on \03{lightpurple}%s\03{default} <<<<\n' % page.title())
-                        wikipedia.output(localImagePage.get())
-                        wikipedia.output(u'\n\n>>>> Description on \03{lightpurple}%s\03{default} <<<<\n' % commonsImagePage.title())
-                        wikipedia.output(commonsText)
-                        choice = wikipedia.inputChoice(u'Does the description on Commons contain all required source and license information?', ['yes', 'no'], ['y', 'N'], 'N')
-                        if choice == 'y':
+                if replaceonly == False:
+                    if md5 == commonsImagePage.getFileMd5Sum():
+                        wikipedia.output(u'The image is identical to the one on Commons.')
+                        if autonomous == False:
+                            wikipedia.output(u'\n\n>>>> Description on \03{lightpurple}%s\03{default} <<<<\n' % page.title())
+                            wikipedia.output(localImagePage.get())
+                            wikipedia.output(u'\n\n>>>> Description on \03{lightpurple}%s\03{default} <<<<\n' % commonsImagePage.title())
+                            wikipedia.output(commonsText)
+                            choice = wikipedia.inputChoice(u'Does the description on Commons contain all required source and license information?', ['yes', 'no'], ['y', 'N'], 'N')
+                            if choice == 'y':
+                                localImagePage.delete(comment + ' [[:commons:Image:%s]]' % filenameOnCommons, prompt = False)
+                        else:
                             localImagePage.delete(comment + ' [[:commons:Image:%s]]' % filenameOnCommons, prompt = False)
                     else:
-                        localImagePage.delete(comment + ' [[:commons:Image:%s]]' % filenameOnCommons, prompt = False)
-                else:
-                    wikipedia.output(u'The image is not identical to the one on Commons.')
+                        wikipedia.output(u'The image is not identical to the one on Commons.')
             except (wikipedia.NoPage, wikipedia.IsRedirectPage), e:
                 wikipedia.output(u'%s' % e)
                 continue





More information about the Pywikipedia-l mailing list