Skip to content

Commit

Permalink
Merge pull request #173 from bis-med-it/annotations_title
Browse files Browse the repository at this point in the history
Annotations title
  • Loading branch information
sosna authored Jan 16, 2025
2 parents 4d38951 + 72d0bc5 commit 6c89bc1
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/pysdmx/io/json/fusion/messages/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def __handle_date(self, datestr: str) -> datetime:
def __get_val(
self, a: FusionAnnotation
) -> Tuple[Optional[datetime], Optional[datetime]]:
vals = a.title.split("/")
if a.title.startswith("/"):
vals = a.title.split("/") # type: ignore[union-attr]
if a.title.startswith("/"): # type: ignore[union-attr]
return (None, self.__handle_date(vals[1]))
else:
valid_from = self.__handle_date(vals[0])
Expand Down
17 changes: 10 additions & 7 deletions src/pysdmx/io/json/fusion/messages/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@
from pysdmx.util import find_by_urn


class FusionAnnotation(msgspec.Struct, frozen=True):
"""Fusion-JSON payload for annotations."""

title: str
type: str


class FusionString(msgspec.Struct, frozen=True):
"""Fusion-JSON payload for an international string."""

locale: str
value: str


class FusionAnnotation(msgspec.Struct, frozen=True):
"""Fusion-JSON payload for annotations."""

id: Optional[str] = None
title: Optional[str] = None
type: Optional[str] = None
value: Optional[str] = None
text: Sequence[FusionString] = ()


class FusionLink(msgspec.Struct, frozen=True):
"""Fusion-JSON payload for link objects."""

Expand Down
8 changes: 8 additions & 0 deletions tests/api/fmr/samples/code/freq.fusion.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
"value": "N:Annual"
}
]
},
{
"text": [
{
"locale": "en",
"value": "Empty"
}
]
}
],
"names": [
Expand Down
6 changes: 6 additions & 0 deletions tests/api/fmr/samples/code/freq.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
"texts": {
"en": "N:Annual"
}
},
{
"text": "Empty",
"texts": {
"en": "Empty"
}
}
],
"name": "Annual",
Expand Down
54 changes: 27 additions & 27 deletions tests/api/fmr/samples/df/tmp_dataflow_with_has.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).MDD",
"annotations": [
{
"title": "cemejuma",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand Down Expand Up @@ -82,7 +82,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).SFT",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -100,7 +100,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down Expand Up @@ -158,7 +158,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).CBS",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -176,7 +176,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down Expand Up @@ -268,7 +268,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).FIDA",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -286,7 +286,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand All @@ -310,7 +310,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).DER",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -328,7 +328,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down Expand Up @@ -403,7 +403,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).EXR",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -421,7 +421,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand All @@ -445,7 +445,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).LBS",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -463,7 +463,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down Expand Up @@ -600,7 +600,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).XTD",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -618,7 +618,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down Expand Up @@ -1174,7 +1174,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).DEBT_SEC",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -1192,7 +1192,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down Expand Up @@ -1343,7 +1343,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).GLI",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -1361,7 +1361,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down Expand Up @@ -2203,7 +2203,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).TFFS",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -2221,7 +2221,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down Expand Up @@ -3686,7 +3686,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).SEC",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -3704,7 +3704,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down Expand Up @@ -4074,7 +4074,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).IDS",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -4092,7 +4092,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down Expand Up @@ -4179,7 +4179,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).DEALOGIC",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -4197,7 +4197,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down
4 changes: 2 additions & 2 deletions tests/api/fmr/samples/pra/hierarchy_hca.fusion.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).CBS",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -48,7 +48,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down
4 changes: 2 additions & 2 deletions tests/api/fmr/samples/pra/no_hca.fusion.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).CBS",
"annotations": [
{
"title": "cbmemcpa",
"title": "xx000000",
"type": "contact_uid"
}
],
Expand All @@ -48,7 +48,7 @@
],
"contacts": [
{
"id": "cbmemcpa",
"id": "xx000000",
"roles": [
{
"locale": "en",
Expand Down

0 comments on commit 6c89bc1

Please sign in to comment.