Revision: 5888 Author: multichill Date: 2008-09-12 14:30:28 +0000 (Fri, 12 Sep 2008)
Log Message: ----------- Changed some filtering options.
Modified Paths: -------------- trunk/pywikipedia/imagerecat.py
Modified: trunk/pywikipedia/imagerecat.py =================================================================== --- trunk/pywikipedia/imagerecat.py 2008-09-12 14:27:55 UTC (rev 5887) +++ trunk/pywikipedia/imagerecat.py 2008-09-12 14:30:28 UTC (rev 5888) @@ -54,11 +54,8 @@ commonshelperCats = [] else: commonshelperCats = getCommonshelperCats(imagepage) - newcats = filterBlacklist(commonshelperCats+currentCats) - newcats = filterDisambiguation(newcats) - newcats = followRedirects(newcats) - newcats = filterCountries(newcats) - newcats = filterParents(newcats) + newcats = applyAllFilters(commonshelperCats+currentCats) + if (len(newcats) > 0 and not(set(currentCats)==set(newcats))): for cat in newcats: wikipedia.output(u' Found new cat: ' + cat); @@ -104,6 +101,16 @@ return list(set(result))
+def applyAllFilters(categories): + result = [] + result = filterBlacklist(categories) + result = filterDisambiguation(result) + result = followRedirects(result) + result = filterCountries(result) + result = filterParents(result) + return result + + def filterBlacklist(categories): ''' Filter out categories which are on the blacklist. @@ -198,8 +205,11 @@ ''' Remove the old categories and add the new categories to the image. ''' - newtext = wikipedia.removeCategoryLinks(imagepage.get(), imagepage.site()) - newtext = removeTemplates(newtext) + u'{{subst:chc}}\n' + newtext = wikipedia.removeCategoryLinks(imagepage.get(), imagepage.site()) + + if not(onlyfilter): + newtext = removeTemplates(newtext) + newtext = newtext + u'{{subst:chc}}\n' for category in newcats: newtext = newtext + u'[[Category:' + category + u']]\n'
pywikipedia-l@lists.wikimedia.org