http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10152
Revision: 10152 Author: amir Date: 2012-04-25 18:16:32 +0000 (Wed, 25 Apr 2012) Log Message: ----------- Adding categories sort for Persian Wikipedia
Modified Paths: -------------- trunk/pywikipedia/cosmetic_changes.py
Modified: trunk/pywikipedia/cosmetic_changes.py =================================================================== --- trunk/pywikipedia/cosmetic_changes.py 2012-04-25 16:55:53 UTC (rev 10151) +++ trunk/pywikipedia/cosmetic_changes.py 2012-04-25 18:16:32 UTC (rev 10152) @@ -295,6 +295,14 @@
# Adding categories if categories: + #Sorting categories in alphabetic order. beta test only on Persian Wikipedia + if self.site.language() == 'fa': + categories.sort() + #Taking main cats to top + for name in categories: + if re.search(u"(.+?)|(.{,1}?)",name.title()) or name.title()==name.title().split(":")[0]+title: + categories.remove(name) + categories.insert(0, name) text = pywikibot.replaceCategoryLinks(text, categories, site=self.site) # Put the iw message back
pywikipedia-svn@lists.wikimedia.org