http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11430
Revision: 11430 Author: legoktm Date: 2013-04-22 09:52:39 +0000 (Mon, 22 Apr 2013) Log Message: ----------- Expose the sortkey options in Category.articles so pagegenerators can use it.
This fixes the breakage that occured in r11267 and completes the fixme from r11401.
Modified Paths: -------------- branches/rewrite/pywikibot/page.py branches/rewrite/pywikibot/pagegenerators.py
Modified: branches/rewrite/pywikibot/page.py =================================================================== --- branches/rewrite/pywikibot/page.py 2013-04-22 09:37:03 UTC (rev 11429) +++ branches/rewrite/pywikibot/page.py 2013-04-22 09:52:39 UTC (rev 11430) @@ -1722,7 +1722,9 @@
@deprecate_arg("startFrom", None) def articles(self, recurse=False, step=None, total=None, - content=False, namespaces=None): + content=False, namespaces=None, sortby="", + starttime=None, endtime=None,startsort=None, + endsort=None): """ Yields all articles in the current category.
@@ -1741,6 +1743,23 @@ @type namespace: int or list of ints @param content: if True, retrieve the content of the current version of each page (default False) + @param sortby: determines the order in which results are generated, + valid values are "sortkey" (default, results ordered by category + sort key) or "timestamp" (results ordered by time page was + added to the category). This applies recursively. + @type sortby: str + @param starttime: if provided, only generate pages added after this + time; not valid unless sortby="timestamp" + @type starttime: pywikibot.Timestamp + @param endtime: if provided, only generate pages added before this + time; not valid unless sortby="timestamp" + @type endtime: pywikibot.Timestamp + @param startsort: if provided, only generate pages >= this title + lexically; not valid if sortby="timestamp" + @type startsort: str + @param endsort: if provided, only generate pages <= this title + lexically; not valid if sortby="timestamp" + @type endsort: str
""" if namespaces is None: @@ -1749,7 +1768,10 @@ for member in self.site.categorymembers(self, namespaces=namespaces, step=step, total=total, - content=content): + content=content, sortby=sortby, + starttime=starttime, endtime=endtime, + startsort=startsort, endsort=endsort, + ): yield member if total is not None: total -= 1 @@ -1761,7 +1783,10 @@ for subcat in self.subcategories(step=step): for article in subcat.articles(recurse, step=step, total=total, content=content, - namespaces=namespaces): + namespaces=namespaces, sortby=sortby, + starttime=starttime, endtime=endtime, + startsort=startsort, endsort=endsort, + ): yield article if total is not None: total -= 1
Modified: branches/rewrite/pywikibot/pagegenerators.py =================================================================== --- branches/rewrite/pywikibot/pagegenerators.py 2013-04-22 09:37:03 UTC (rev 11429) +++ branches/rewrite/pywikibot/pagegenerators.py 2013-04-22 09:52:39 UTC (rev 11430) @@ -604,18 +604,14 @@ retrieved page will be downloaded.
""" - kwargs = dict(recurse=recurse, - step=step, - total=total, - content=content, - ) + kwargs = dict(recurse=recurse, step=step, total=total, + content=content) if start: kwargs['sortby'] = 'sortkey' kwargs['startsort'] = start - for a in category.site.categorymembers(category, **kwargs): + for a in category.articles(**kwargs): yield a
- def SubCategoriesPageGenerator(category, recurse=False, start=None, step=None, total=None, content=False): """Yield all subcategories in a specific category.
pywikipedia-svn@lists.wikimedia.org