ds-caselaw-marklogic-api-client 29.0.0__py3-none-any.whl → 29.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ds-caselaw-marklogic-api-client might be problematic. Click here for more details.

@@ -177,6 +177,6 @@ class Identifiers(dict[str, Identifier]):
177
177
 
178
178
  :return: Return the highest scoring identifier of the given type (or of any type, if none is specified). Returns `None` if no identifier is available.
179
179
  """
180
- if len(self) == 0:
180
+ if len(self.by_score(type)) == 0:
181
181
  return None
182
182
  return self.by_score(type)[0]
@@ -1,4 +1,5 @@
1
1
  from typing import Optional
2
+ from warnings import warn
2
3
 
3
4
  from lxml import etree
4
5
 
@@ -19,12 +20,13 @@ def unpack_all_identifiers_from_etree(identifiers_etree: Optional[etree._Element
19
20
  return identifiers
20
21
  for identifier_etree in identifiers_etree.findall("identifier"):
21
22
  identifier = unpack_an_identifier_from_etree(identifier_etree)
22
- identifiers.add(identifier)
23
+ if identifier:
24
+ identifiers.add(identifier)
23
25
  return identifiers
24
26
 
25
27
 
26
- def unpack_an_identifier_from_etree(identifier_xml: etree._Element) -> Identifier:
27
- """Given an etree representation of a single identifier, unpack it into an appropriate instance of an Identifier."""
28
+ def unpack_an_identifier_from_etree(identifier_xml: etree._Element) -> Optional[Identifier]:
29
+ """Given an etree representation of a single identifier, unpack it into an appropriate instance of an Identifier if the type is known (otherwise return `None`)."""
28
30
 
29
31
  namespace_element = identifier_xml.find("namespace")
30
32
 
@@ -33,6 +35,11 @@ def unpack_an_identifier_from_etree(identifier_xml: etree._Element) -> Identifie
33
35
  "Identifer XML representation is not valid: namespace not present or empty"
34
36
  )
35
37
 
38
+ # If the identifier namespace isn't known, fail out
39
+ if namespace_element.text not in IDENTIFIER_NAMESPACE_MAP:
40
+ warn(f"Identifier type {namespace_element.text} is not known.")
41
+ return None
42
+
36
43
  kwargs: dict[str, str] = {}
37
44
 
38
45
  for attribute in IDENTIFIER_UNPACKABLE_ATTRIBUTES:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ds-caselaw-marklogic-api-client
3
- Version: 29.0.0
3
+ Version: 29.0.1
4
4
  Summary: An API client for interacting with the underlying data in Find Caselaw.
5
5
  Home-page: https://github.com/nationalarchives/ds-caselaw-custom-api-client
6
6
  Keywords: national archives,caselaw
@@ -13,10 +13,10 @@ caselawclient/models/documents/exceptions.py,sha256=rw1xId16vBKvBImgFmFUpeFgKqU7
13
13
  caselawclient/models/documents/statuses.py,sha256=Cp4dTQmJOtsU41EJcxy5dV1841pGD2PNWH0VrkDEv4Q,579
14
14
  caselawclient/models/documents/transforms/html.xsl,sha256=oSSO-IBX4qLiSWexQYmWJfGNevF09aCBx4D1NYqXxpo,38322
15
15
  caselawclient/models/documents/xml.py,sha256=HlmPb63lLMnySSOLP4iexcAyQiLByKBZtTd25f8sY8M,1268
16
- caselawclient/models/identifiers/__init__.py,sha256=4D_ssfNK7gj7Z4XMHqCzn-EwsPM4a6IofYkU1JjnRF4,6449
16
+ caselawclient/models/identifiers/__init__.py,sha256=9DtWdBQYrdiQC_LPyG-nnEj22vNJyuy9KSBTwSlN8EI,6464
17
17
  caselawclient/models/identifiers/fclid.py,sha256=pTO586ra0sr4DbjHSxuI8UlxfNXLm9nDNVoDUIxiUrE,1354
18
18
  caselawclient/models/identifiers/neutral_citation.py,sha256=3Jw1_-NmGfGmrWGFSzLdTHBYHIHq4tPkF8U7Jba-jGo,1848
19
- caselawclient/models/identifiers/unpacker.py,sha256=01gWWlOd_2PxT1GJzOIXbp0G4iGGIxHaTaJMBOQ1TDs,1834
19
+ caselawclient/models/identifiers/unpacker.py,sha256=xvp480QESbN36NEc6qeo-orqOBq6WchnLI7thY7A1qs,2156
20
20
  caselawclient/models/judgments.py,sha256=xFjfOspa9ZL29gvvGVNq11JC7h-LKebFMrQYvVIIoEI,1868
21
21
  caselawclient/models/neutral_citation_mixin.py,sha256=LDaxNndLcTKsjJCyEKO1kGTJ6YD6h-6SzQVE0-gwPSI,2208
22
22
  caselawclient/models/press_summaries.py,sha256=bEqJxu-7eBLhwulOsDXYDl2ptIp3RkkMpOcdVvWB5ds,1836
@@ -77,7 +77,7 @@ caselawclient/xquery/validate_document.xqy,sha256=PgaDcnqCRJPIVqfmWsNlXmCLNKd21q
77
77
  caselawclient/xquery/xslt.xqy,sha256=w57wNijH3dkwHkpKeAxqjlghVflQwo8cq6jS_sm-erM,199
78
78
  caselawclient/xquery/xslt_transform.xqy,sha256=smyFFxqmtkuOzBd2l7uw6K2oAsYctudrP8omdv_XNAM,2463
79
79
  caselawclient/xquery_type_dicts.py,sha256=kybL-YzwK34Fr6MeWfqVOJHYrs0ZNeDWXDsp8o2Yb1U,6114
80
- ds_caselaw_marklogic_api_client-29.0.0.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
81
- ds_caselaw_marklogic_api_client-29.0.0.dist-info/METADATA,sha256=x0GZ0GgA91sa_O9Eq2aal3FONl6Vs2lknsPdrPUmlzE,4272
82
- ds_caselaw_marklogic_api_client-29.0.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
83
- ds_caselaw_marklogic_api_client-29.0.0.dist-info/RECORD,,
80
+ ds_caselaw_marklogic_api_client-29.0.1.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
81
+ ds_caselaw_marklogic_api_client-29.0.1.dist-info/METADATA,sha256=6r95tWetaoYKAZq0gj8l44h_iTSuXpSkIDCFWzQxLX8,4272
82
+ ds_caselaw_marklogic_api_client-29.0.1.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
83
+ ds_caselaw_marklogic_api_client-29.0.1.dist-info/RECORD,,