Skip to content

Commit

Permalink
Add a field to distinguish top-level items from others
Browse files Browse the repository at this point in the history
I think I'll need this for the wikidata completeness filter to only give
results for top-level items, since giving results for their parts would
just duplicate the results needlessly.
  • Loading branch information
dseomn committed Oct 29, 2023
1 parent 47353c6 commit 3c264a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rock_paper_sand/media_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class MediaItem:
custom_data: Parsed proto.custom_data field, or None.
done: Parsed proto.done field.
wikidata_item: Wikidata item, or None.
has_parent: Whether or not this item appears in the `parts` field of
another item.
parts: Parsed proto.parts field.
"""

Expand All @@ -54,6 +56,7 @@ class MediaItem:
custom_data: Any
done: multi_level_set.MultiLevelSet
wikidata_item: wikidata_value.Item | None
has_parent: bool
parts: Sequence["MediaItem"]

@classmethod
Expand Down Expand Up @@ -115,6 +118,7 @@ def from_config(
if proto.wikidata
else None
),
has_parent=parent_fully_qualified_name is not None,
parts=parts,
)

Expand Down
2 changes: 2 additions & 0 deletions rock_paper_sand/media_item_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_from_config(self) -> None:
custom_data={"a": "b"},
done=mock.ANY,
wikidata_item=wikidata_value.Item("Q1"),
has_parent=False,
parts=(
media_item.MediaItem(
id=mock.ANY,
Expand All @@ -64,6 +65,7 @@ def test_from_config(self) -> None:
custom_data=None,
done=mock.ANY,
wikidata_item=None,
has_parent=True,
parts=(),
),
),
Expand Down

0 comments on commit 3c264a1

Please sign in to comment.