Skip to content
Snippets Groups Projects
Commit 1497c935 authored by Dan Michael O. Heggø's avatar Dan Michael O. Heggø
Browse files

Merge pull request #108 from AdamWill/py3-generatorlist

[#106] fix GeneratorList with Python 3 (add __next__)
parents 8e729fde 7522c02b
No related branches found
No related tags found
No related merge requests found
...@@ -57,7 +57,7 @@ class List(object): ...@@ -57,7 +57,7 @@ class List(object):
if self.last: if self.last:
raise StopIteration raise StopIteration
self.load_chunk() self.load_chunk()
return List.next(self, full=full) return List.__next__(self, full=full)
def next(self, full=False): def next(self, full=False):
""" For Python 2.x support """ """ For Python 2.x support """
...@@ -139,14 +139,18 @@ class GeneratorList(List): ...@@ -139,14 +139,18 @@ class GeneratorList(List):
self.page_class = mwclient.page.Page self.page_class = mwclient.page.Page
def next(self): def __next__(self):
info = List.next(self, full=True) info = List.__next__(self, full=True)
if info['ns'] == 14: if info['ns'] == 14:
return Category(self.site, u'', info) return Category(self.site, u'', info)
if info['ns'] == 6: if info['ns'] == 6:
return mwclient.image.Image(self.site, u'', info) return mwclient.image.Image(self.site, u'', info)
return mwclient.page.Page(self.site, u'', info) return mwclient.page.Page(self.site, u'', info)
def next(self):
""" For Python 2.x support """
return self.__next__()
def load_chunk(self): def load_chunk(self):
# Put this here so that the constructor does not fail # Put this here so that the constructor does not fail
# on uninitialized sites # on uninitialized sites
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment