Revision: 6047 Author: filnik Date: 2008-11-01 10:13:21 +0000 (Sat, 01 Nov 2008)
Log Message: ----------- Little bugfix
Modified Paths: -------------- trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py =================================================================== --- trunk/pywikipedia/checkimages.py 2008-10-31 10:41:00 UTC (rev 6046) +++ trunk/pywikipedia/checkimages.py 2008-11-01 10:13:21 UTC (rev 6047) @@ -1153,7 +1153,7 @@ self.hiddentemplates = self.loadHiddenTemplates() self.licenses_found = self.image.getTemplates() self.whiteTemplatesFound = False - regex_find_licenses = re.compile(r'(?<!{){{(?:[Tt]emplate:|)([^{]*?)[|\n<}]', re.DOTALL) + regex_find_licenses = re.compile(r'(?<!{){{(?:[Tt]emplate:|)([^{]+?)[|\n<}]', re.DOTALL) templatesInTheImageRaw = regex_find_licenses.findall(self.imageCheckText) self.allLicenses = list() if self.list_licenses == []: @@ -1168,7 +1168,16 @@ if self.licenses_found != []: self.templateInList() if self.license_found == None and self.allLicenses != list(): - self.license_found = self.license_selected + iterLicenses = self.allLicenses + for template in iterLicenses: + try: + template.pageAPInfo() + except wikipedia.IsRedirectPage: + template = template.getRedirectTarget() + except wikipedia.NoPage: + self.allLicenses.remove(template) + if self.allLicenses != list(): + self.license_found = self.allLicenses[0].title() if not self.seems_ok and self.license_found != None: rep_text_license_fake = u"\n*[[:Image:%s]] seems to have " % self.imageName + \ "a ''fake license'', license detected: <nowiki>%s</nowiki>" % self.license_found