http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11013
Revision: 11013 Author: multichill Date: 2013-01-28 20:55:48 +0000 (Mon, 28 Jan 2013) Log Message: ----------- Also include sortkeyprefix
Modified Paths: -------------- trunk/pywikipedia/catlib.py
Modified: trunk/pywikipedia/catlib.py =================================================================== --- trunk/pywikipedia/catlib.py 2013-01-28 20:45:24 UTC (rev 11012) +++ trunk/pywikipedia/catlib.py 2013-01-28 20:55:48 UTC (rev 11013) @@ -66,9 +66,10 @@ """Subclass of Page that has some special tricks that only work for category: pages"""
- def __init__(self, site, title = None, insite = None, sortKey = None): + def __init__(self, site, title = None, insite = None, sortKey = None, sortKeyPrefix = None): wikipedia.Page.__init__(self, site = site, title = title, insite = insite, defaultNamespace = 14) self.sortKey = sortKey + self.sortKeyPrefix = sortKeyPrefix if self.namespace() != 14: raise ValueError(u'BUG: %s is not in the category namespace!' % title) self.completelyCached = False @@ -206,7 +207,7 @@ 'action': 'query', 'list': 'categorymembers', 'cmtitle': self.title(), - 'cmprop': ['title', 'ids', 'sortkey', 'timestamp'], + 'cmprop': ['title', 'ids', 'sortkey', 'sortkeyprefix', 'timestamp'], #'': '', } if sortby: @@ -245,7 +246,7 @@ count += 1 # For MediaWiki versions where subcats look like articles if memb['ns'] == 14: - yield SUBCATEGORY, Category(self.site(), memb['title'], sortKey=memb['sortkey']) + yield SUBCATEGORY, Category(self.site(), memb['title'], sortKey=memb['sortkey'], sortKeyPrefix=memb['sortkeyprefix']) elif memb['ns'] == 6: yield ARTICLE, wikipedia.ImagePage(self.site(), memb['title']) else:
pywikipedia-svn@lists.wikimedia.org