From f6cbaab70629fcac89cabe30ce1dc6d9eb0e8358 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Apr 20 2016 22:33:33 +0000 Subject: add 'end' support back to TcmsPageList and the generators so I took this out during the python3 conversion, but it turns out that was wrong. The 'end' support never got merged upstream and there *is* something that uses it: my 'testdays' CLI app (not to be confused with the 'testdays' web app, boy we stink at naming). So this adds it back, in a slightly different way which reduces unnecessary duplication of upstream as far as possible. I've sent https://github.com/mwclient/mwclient/pull/114 to add this upstream, so hopefully that gets merged and we can drop the divergence again downstream, just keeping the args. --- diff --git a/wikitcms/listing.py b/wikitcms/listing.py index 0105e0c..718ffb3 100644 --- a/wikitcms/listing.py +++ b/wikitcms/listing.py @@ -202,6 +202,17 @@ class TcmsPageList(mwl.PageList, TcmsGeneratorList): """A version of PageList which returns wikitcms page (and category etc.) objects when appropriate. """ + def __init__(self, site, prefix=None, start=None, namespace=0, + redirects='all', end=None): + super(TcmsPageList, self).__init__( + site, prefix=prefix, start=start, namespace=namespace, + redirects=redirects) + if end: + # this is adding a feature missing from upstream, used by + # testdays; can be removed if + # https://github.com/mwclient/mwclient/pull/114 is merged + self.args['gapto'] = end + def get(self, name, info=()): modname = name if self.namespace: diff --git a/wikitcms/wiki.py b/wikitcms/wiki.py index c9ad42c..a4f9abc 100644 --- a/wikitcms/wiki.py +++ b/wikitcms/wiki.py @@ -158,7 +158,7 @@ class Wiki(mwclient.Site): pages = pages.values() return pages - def allresults(self, prefix=None, start=None, redirects='all'): + def allresults(self, prefix=None, start=None, redirects='all', end=None): """A generator for pages in the Test Results: namespace, similar to mwclient's allpages, allcategories etc. generators. This is a TcmsPageList, so it returns wikitcms objects when @@ -166,10 +166,10 @@ class Wiki(mwclient.Site): the "Test Results:" part of the name. """ gen = li.TcmsPageList(self, prefix=prefix, start=start, - namespace=116, redirects=redirects) + namespace=116, redirects=redirects, end=end) return gen - def alltestdays(self, prefix=None, start=None, redirects='all'): + def alltestdays(self, prefix=None, start=None, redirects='all', end=None): """A generator for pages in the Test Day: namespace, similar to mwclient's allpages, allcategories etc. generators. This is a TcmsPageList, so it returns wikitcms objects when @@ -177,7 +177,7 @@ class Wiki(mwclient.Site): the "Test Day:" part of the name. """ gen = li.TcmsPageList(self, prefix=prefix, start=start, - namespace=114, redirects=redirects) + namespace=114, redirects=redirects, end=end) return gen def _check_compose(self, compose):