Page MenuHomePhabricator

flow.Board.topics continuation breaks when reverse=True
Closed, ResolvedPublic

Description

When using board.topics(reverse=True), after the first batch has been iterated (default is 100 topics), the generator fails with KeyError.

from pywikibot.flow import Board
site = pywikibot.Site('mediawiki', 'mediawiki')
board = Board(site, 'Project talk:Sandbox/Flow test')
topics_list = board.topics(reverse=True)
for topic in topics_list:
    print(topic)

results in

[[mediawiki:Topic:Sojpiv245cuiw67c]]
[[mediawiki:Topic:Sofvr5snmpjxk7po]]
[[mediawiki:Topic:Sofvkmr22vxpo1x4]]
[[mediawiki:Topic:Socee2qdhcihhfaf]]
[[mediawiki:Topic:So9nobp64639g1l8]]
[[mediawiki:Topic:So6onix7tg6u22y0]]
[[mediawiki:Topic:So2r9kvmvvmo32to]]
[[mediawiki:Topic:So1soxbq2h0ju3uz]]
...
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "pywikibot/flow.py", line 139, in topics
    cont_args = self._parse_url(data['links']['pagination'])
  File "pywikibot/flow.py", line 93, in _parse_url
    rule = links['fwd']
KeyError: u'fwd'

Event Timeline

This was a remarkably simple oversight on my part. When the topic list is reversed, the proper key is "rev" rather than "fwd".

Change 805484 had a related patch set uploaded (by Happy5214; author: Happy5214):

[pywikibot/core@master] Fix Flow board topic continuation when iterating in reverse

https://gerrit.wikimedia.org/r/805484

Xqt assigned this task to happy5214.

Change 805484 merged by jenkins-bot:

[pywikibot/core@master] Fix Flow board topic continuation when iterating in reverse

https://gerrit.wikimedia.org/r/805484