Skip to content

Commit 7700579

Browse files
authored
Merge pull request #8 from kmaehashi/faster-tag-discovery
remove unnecessary sleep and request during tag list
2 parents 3fbed4b + 42e61a4 commit 7700579

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

atwiki/core.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ def get_tags(self):
7272
count += 1
7373
yield {'name': tag_name, 'weight': tag_weight}
7474
if count == 0: break
75+
76+
pagerArea = soup.find('div', attrs={'class': 'cmd_tag'}).find('div')
77+
if pagerArea is None:
78+
# Pager area will not be shown when tag list fits in one page.
79+
assert index == 0
80+
break
81+
pagers = pagerArea.findAll('a')
82+
if len(pagers) == 1:
83+
if pagers[0].attrs['href'].endswith('/?p={}'.format(index - 1)):
84+
# Valid pager found, and no more tags.
85+
break
7586
index += 1
7687
time.sleep(self._sleep)
7788

0 commit comments

Comments
 (0)