Revision: 8337
Author: filnik
Date: 2010-06-26 12:22:22 +0000 (Sat, 26 Jun 2010)
Log Message:
-----------
New function: skip service images
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2010-06-26 11:57:06 UTC (rev 8336)
+++ trunk/pywikipedia/checkimages.py 2010-06-26 12:22:22 UTC (rev 8337)
@@ -471,6 +471,14 @@
'commons':[['File Upload Bot (Magnus Manske)', r'\|[Ss]ource=Transferred from .*?; transferred to Commons by \[\[User:(.*?)\]\]']],
}
+# Service images that don't have to be deleted and/or reported has a template inside them
+# (you can let this param as None)
+
+serviceTemplates = {
+ '_default': None,
+ 'it': ['Template:Immagine di servizio'],
+}
+
# Add your project (in alphabetical order) if you want that the bot start
project_inserted = [u'ar', u'commons', u'de', u'en', u'fa', u'ga', u'hu', u'it', u'ja', u'ko', u'ta', u'zh']
@@ -862,6 +870,13 @@
else:
commons_image_with_this_hash = commons_site.getFilesFromAnHash(hash_found)
if commons_image_with_this_hash != [] and commons_image_with_this_hash != 'None':
+ servTMP = wikipedia.translate(self.site, serviceTemplates)
+ templatesInTheImage = self.image.getTemplates()
+ if servTMP != None:
+ for template in servTMP:
+ if wikipedia.Page(self.site, template) in templatesInTheImage:
+ wikipedia.output(u"%s is on commons but it's a service image." % self.imageName)
+ return True # Problems? No, return True and continue with the check-part
wikipedia.output(u'%s is on commons!' % self.imageName)
on_commons_text = self.image.getImagePageHtml()
if u"<div class='sharedUploadNotice'>" in on_commons_text:
@@ -879,11 +894,9 @@
else:
repme = u"\n*[[:File:%s]] is also on '''Commons''': [[commons:File:%s]]" % (self.imageName, commons_image_with_this_hash[0])
self.report_image(self.imageName, self.rep_page, self.com, repme, addings = False, regex = regexOnCommons)
- # Problems? No, return True
- return True
+ return True # Problems? No, return True
else:
- # Problems? No, return True
- return True
+ return True # Problems? No, return True
def checkImageDuplicated(self, duplicates_rollback):
""" Function to check the duplicated files. """
Revision: 8333
Author: xqt
Date: 2010-06-25 16:28:39 +0000 (Fri, 25 Jun 2010)
Log Message:
-----------
move test script to tests folder
Added Paths:
-----------
trunk/pywikipedia/tests/test_xml.py
Removed Paths:
-------------
trunk/pywikipedia/xmltest.py
Copied: trunk/pywikipedia/tests/test_xml.py (from rev 8326, trunk/pywikipedia/xmltest.py)
===================================================================
--- trunk/pywikipedia/tests/test_xml.py (rev 0)
+++ trunk/pywikipedia/tests/test_xml.py 2010-06-25 16:28:39 UTC (rev 8333)
@@ -0,0 +1,19 @@
+"""This is a minimal script to parse an XML file such as the sax_parse_bug.dat
+dumps that interwiki.py can make if something fails. The only goal of this
+program is to get a stack trace listing line number and column of the invalid
+character in the XML.
+
+Pass this script the name of an XML file as argument.
+"""
+#
+# (C) Rob W.W. Hooft, 2003
+#
+# Distributed under the terms of the MIT license.
+#
+__version__ = '$Id$'
+#
+import sys, xml.sax, xml.sax.handler
+
+h = xml.sax.handler.ContentHandler()
+xml.sax.parse(open(sys.argv[1], 'r'), h)
+
Deleted: trunk/pywikipedia/xmltest.py
===================================================================
--- trunk/pywikipedia/xmltest.py 2010-06-25 15:02:58 UTC (rev 8332)
+++ trunk/pywikipedia/xmltest.py 2010-06-25 16:28:39 UTC (rev 8333)
@@ -1,19 +0,0 @@
-"""This is a minimal script to parse an XML file such as the sax_parse_bug.dat
-dumps that interwiki.py can make if something fails. The only goal of this
-program is to get a stack trace listing line number and column of the invalid
-character in the XML.
-
-Pass this script the name of an XML file as argument.
-"""
-#
-# (C) Rob W.W. Hooft, 2003
-#
-# Distributed under the terms of the MIT license.
-#
-__version__ = '$Id$'
-#
-import sys, xml.sax, xml.sax.handler
-
-h = xml.sax.handler.ContentHandler()
-xml.sax.parse(open(sys.argv[1], 'r'), h)
-