Skip to content

Commit

Permalink
fix: title list be truncated if the page name is exactly --END--.
Browse files Browse the repository at this point in the history
  • Loading branch information
yzqzss committed Dec 4, 2024
1 parent 3343127 commit 4ead08d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions wikiteam3/dumpgenerator/api/page_titles.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,23 @@ def read_titles(config: Config, session: requests.Session, start: Optional[str]=
)

seeking = start is not None
""" If True, we are looking for the `start` title to start reading from """
end_reached = False
with open(f"{config.path}/{titles_filename}", encoding="utf-8") as f:
for line in f:
title = line.strip()

if title == "--END--":
break
elif seeking and title != start:
end_reached = True
else:
end_reached = False

if seeking and title != start:
continue
else:
seeking = False

yield title

if not end_reached:
raise EOFError("End of file flag `--END--` not found in the last line")

0 comments on commit 4ead08d

Please sign in to comment.