Skip to content

Commit

Permalink
Update metroninfo.py notes metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
bpepple committed Oct 13, 2024
1 parent e54ad75 commit 5e437a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions darkseid/metroninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Credit,
InfoSources,
Metadata,
Notes,
Price,
Publisher,
Role,
Expand Down Expand Up @@ -383,7 +384,8 @@ def convert_metadata_to_xml(self, md: Metadata, xml=None) -> ET.ElementTree: #
self._assign(root, "CoverDate", md.cover_date)
self._assign(root, "StoreDate", md.store_date)
self._assign(root, "PageCount", md.page_count)
self._assign(root, "Notes", md.notes)
if md.notes is not None and md.notes.metron_info:
self._assign(root, "Notes", md.notes.metron_info)
if md.genres:
self._assign_basic_children(root, "Genres", "Genre", md.genres)
if md.tags:
Expand Down Expand Up @@ -580,6 +582,9 @@ def get_urls(url_node: ET.Element) -> URLS | None:
primary = url_node.find("Primary").text
return URLS(primary, url_lst)

def get_note(note_node: ET.Element) -> Notes | None:
return None if note_node is None else Notes(note_node.text)

def get_credits(credits_node: ET.Element) -> list[Credit] | None:
if credits_node is None:
return None
Expand Down Expand Up @@ -613,6 +618,7 @@ def get_credits(credits_node: ET.Element) -> list[Credit] | None:
credits_node = root.find("Credits")
prices_node = root.find("Prices")
url_node = root.find("URLs")
note_node = root.find("Notes")

md = Metadata()
md.info_source = get_info_sources(id_node)
Expand All @@ -633,7 +639,7 @@ def get_credits(credits_node: ET.Element) -> list[Credit] | None:
)
p_count = get("PageCount")
md.page_count = int(p_count) if p_count is not None and p_count.isdigit() else None
md.notes = get("Notes")
md.notes = get_note(note_node)
md.genres = get_resource_list(root.find("Genres"))
md.tags = get_resource_list(root.find("Tags"))
md.story_arcs = get_arcs(arcs_node)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_metroninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Credit,
InfoSources,
Metadata,
Notes,
Price,
Publisher,
Role,
Expand Down Expand Up @@ -120,6 +121,7 @@ def test_convert_metadata_to_xml(metron_info):
tags=[Basic("Good", id_=1)],
locations=[Basic("Atlantis", id_=90)],
reprints=[Basic("Action Comics #1", id_=1)],
notes=Notes(metron_info="This is a test"),
)

# Act
Expand Down Expand Up @@ -180,6 +182,7 @@ def test_metadata_from_string(metron_info):
<Name>Arc1</Name>
</Arc>
</Arcs>
<Notes>This is a test</Notes>
<LastModified>2024-08-12T12:13:54.087728-04:00</LastModified>
<Credits>
<Credit>
Expand Down Expand Up @@ -226,6 +229,8 @@ def test_metadata_from_string(metron_info):
assert result.modified == datetime(
2024, 8, 12, 12, 13, 54, 87728, tzinfo=timezone(timedelta(days=-1, seconds=72000))
)
assert result.notes is not None
assert result.notes.metron_info == "This is a test"


def validate(xml_path: str, xsd_path: str) -> bool:
Expand Down

0 comments on commit 5e437a9

Please sign in to comment.