Skip to content

Commit

Permalink
fix iter bug in dump_entities_to_json (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
galtay authored Nov 9, 2022
1 parent e77f105 commit 04a1867
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion qwikidata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"""Metadata for this package."""

__package_name__ = "qwikidata"
__version__ = "0.4.1"
__version__ = "0.4.2"
6 changes: 3 additions & 3 deletions qwikidata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def dump_entities_to_json(entities: Iterable[WikidataEntity], out_fname: str) ->
"""
with open(out_fname, "w") as fp:
fp.write("[")

ent = next(entities, None)
ent_iter = iter(entities)
ent = next(ent_iter, None)
while ent:
ent_str = json.dumps(ent._entity_dict)
fp.write("\n{}".format(ent_str))
ent = next(entities, None)
ent = next(ent_iter, None)
if ent: fp.write(",")

fp.write("\n]")

0 comments on commit 04a1867

Please sign in to comment.