[Pywikipedia-l] SVN: [5686] trunk/pywikipedia/checkimages.py

filnik at svn.wikimedia.org filnik at svn.wikimedia.org
Sun Jul 6 15:52:11 UTC 2008


Revision: 5686
Author:   filnik
Date:     2008-07-06 15:52:11 +0000 (Sun, 06 Jul 2008)

Log Message:
-----------
Fixing BadTitle, the licenses that rises that error will be automatically reported

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

Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py	2008-07-06 15:48:09 UTC (rev 5685)
+++ trunk/pywikipedia/checkimages.py	2008-07-06 15:52:11 UTC (rev 5686)
@@ -1325,12 +1325,16 @@
                             for license_selected in licenses_found:
                                 #print template.exists()                        
                                 template = wikipedia.Page(site, 'Template:%s' % license_selected)
-                                if template.isRedirectPage():
-                                    template = template.getRedirectTarget()
+                                try:
+                                    if template.isRedirectPage():
+                                        template = template.getRedirectTarget()
+                                except wikipedia.BadTitle:
+                                    seems_ok = False # Template with wrong name
+                                else:
+                                    if template in list_licenses:
+                                        seems_ok = True
+                                        break
                                 license_found = license_selected
-                                if template in list_licenses:
-                                    seems_ok = True
-                                    break
                         if not seems_ok:
                             rep_text_license_fake = "\n*[[:Image:%s]] seems to have a ''fake license'', license detected: {{tl|%s}}." % (imageName, license_found)
                             regexFakeLicense = r"\* ?\[\[:Image:%s\]\] seems to have a ''fake license'', license detected: \{\{tl\|%s\}\}\.$" % (imageName, license_found)





More information about the Pywikipedia-l mailing list