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

filnik at svn.wikimedia.org filnik at svn.wikimedia.org
Wed Jan 23 14:55:27 UTC 2008


Revision: 4925
Author:   filnik
Date:     2008-01-23 14:55:27 +0000 (Wed, 23 Jan 2008)

Log Message:
-----------
Adding a template to skip on commons and make a function more 'powerful'

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

Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py	2008-01-23 14:48:13 UTC (rev 4924)
+++ trunk/pywikipedia/checkimages.py	2008-01-23 14:55:27 UTC (rev 4925)
@@ -81,7 +81,7 @@
 
 # That's what you want that will be added. (i.e. the {{no source}} with the right day/month/year )
 n_txt = {
-        'commons':'\n{{subst:nld}}',
+    'commons':'\n{{subst:nld}}',
     'en'     :'\n{{subst:nld}}',
     'it'     :'\n{{subst:unverdata}}',
     'ja':'{{subst:Nsd}}',
@@ -89,8 +89,13 @@
     'zh'    :'{{subst:No license/auto}}',
 }
 
+# Text that the bot will try to see if there's already or not. If there's a
+# {{ I'll use a regex to make a better check.
+# This will work so:
+# '{{nld' --> '\{\{(?:template:|)no[ _]license ?(?:\||\n|\}) ?' (case insensitive).
+# If there's not a {{ it will work as usual (if x in Text)
 txt_find =  {
-    'commons':['{{no license', '{{nld'],
+    'commons':['{{no license', '{{nld', '{{no permission since'],
         'en':['{{nld', '{{no license'],
     'hu':[u'{{nincsforrás',u'{{nincslicenc'],
     'it':[u'{{unverdata', u'{{unverified'],
@@ -866,11 +871,16 @@
                                 wikipedia.output(u"The file description for %s is a redirect?!" % imageName )
                                 continue
                         for i in TextFind:
-                                if i.lower() in g:
+                                if '{{' in i:
+                                        regexP = re.compile('\{\{(?:template|)%s ?(?:\||\n|\}) ?' % i.split('{{')[1].replace(' ', '[ _]'), re.I)
+                                        result = regexP.findall(g)
+                                        if result != []:
+                                                tagged = True
+                                elif i.lower() in g:
                                         tagged = True				
                         for l in hiddentemplate:
                                 if tagged == False:
-                                        res = re.findall(r'\{\{(?:[Tt]emplate:|)%s(?: \n|\||\n)' % l.lower(), g.lower())
+                                        res = re.findall(r'\{\{(?:[Tt]emplate:|)%s(?: \n|\||\n|\})' % l.lower(), g.lower())
                                         if res != []:
                                                 #print res
                                                 wikipedia.output(u'A white template found, skipping the template...')





More information about the Pywikipedia-l mailing list