Skip to content

Commit

Permalink
Avoid duplicated strings
Browse files Browse the repository at this point in the history
  • Loading branch information
sosna committed Feb 22, 2024
1 parent b4b565d commit bad9281
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/pysdmx/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from pysdmx.errors import NotFound

NF = "Not found"


class Reference(Struct, frozen=True):
"""The coordinates of an SDMX maintainable artefact.
Expand Down Expand Up @@ -58,9 +60,7 @@ def parse_urn(urn: str) -> Reference:
)
else:
raise NotFound(
404,
"Not found",
f"{urn} does not match {maintainable_urn_pattern}",
404, NF, f"{urn} does not match {maintainable_urn_pattern}"
)


Expand All @@ -76,9 +76,7 @@ def parse_item_urn(urn: str) -> ItemReference:
item_id=m.group(5),
)
else:
raise NotFound(
404, "Not found", f"{urn} does not match {item_urn_pattern}."
)
raise NotFound(404, NF, f"{urn} does not match {item_urn_pattern}.")


def find_by_urn(artefacts: Sequence[Any], urn: str) -> Any:
Expand All @@ -95,7 +93,7 @@ def find_by_urn(artefacts: Sequence[Any], urn: str) -> Any:
urns = [f"{a.agency}:{a.id}({a.version})" for a in artefacts]
raise NotFound(
404,
"Not found",
NF,
(
f"Could not find an artefact matching the following URN: "
f"{urn}. The artefacts received were: {urns}."
Expand Down

0 comments on commit bad9281

Please sign in to comment.