ds-caselaw-marklogic-api-client 34.0.0__py3-none-any.whl → 34.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.
@@ -5,6 +5,8 @@ from typing import Any, Optional, TypedDict
5
5
  from lxml import etree
6
6
  from typing_extensions import NotRequired
7
7
 
8
+ from caselawclient.xml_helpers import DEFAULT_NAMESPACES
9
+
8
10
  from ..models.documents import Document
9
11
  from ..models.judgments import Judgment
10
12
  from ..models.press_summaries import PressSummary
@@ -124,19 +126,23 @@ class VersionAnnotation:
124
126
 
125
127
 
126
128
  def get_document_type_class(xml: bytes) -> type[Document]:
127
- """Attempt to get the type of the document based on the XML root node."""
129
+ """Attempt to get the type of the document based on the top-level structure of the XML document."""
128
130
 
129
131
  node = etree.fromstring(xml)
130
132
 
131
- # If the document's root element is `judgment` it's a `Judgment`, regardless of the presence of a `name`.
132
- if node.tag == "judgment":
133
+ # If the main node is `<judgment>`, it's a judgment
134
+ if node.xpath("/akn:akomaNtoso/akn:judgment", namespaces=DEFAULT_NAMESPACES):
133
135
  return Judgment
134
136
 
135
- # If the document's root element has a `name` attribute with a value of `pressSummary` we can assume it's a `PressSummary`
136
- if node.tag == "doc" and node.attrib.get("name") == "pressSummary":
137
+ # If the main node is `<doc name='pressSummary'>`, it's a press summary
138
+ if node.xpath("/akn:akomaNtoso/akn:doc[@name='pressSummary']", namespaces=DEFAULT_NAMESPACES):
137
139
  return PressSummary
138
140
 
141
+ # If the document is a parser error with a root element of `error`, it's not of a special type.
142
+ if node.xpath("/error", namespaces=DEFAULT_NAMESPACES):
143
+ return Document
144
+
139
145
  # Otherwise, we don't know for sure. Fail out.
140
146
  raise CannotDetermineDocumentType(
141
- "Unable to accurately determine the type of document based on the root XML node.",
147
+ "Unable to determine the Document type by its XML",
142
148
  )
@@ -2,6 +2,11 @@ from typing import Dict, Optional
2
2
 
3
3
  from lxml import etree
4
4
 
5
+ DEFAULT_NAMESPACES = {
6
+ "uk": "https://caselaw.nationalarchives.gov.uk/akn",
7
+ "akn": "http://docs.oasis-open.org/legaldocml/ns/akn/3.0",
8
+ }
9
+
5
10
 
6
11
  def get_xpath_match_string(
7
12
  node: etree._Element,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ds-caselaw-marklogic-api-client
3
- Version: 34.0.0
3
+ Version: 34.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
@@ -1,6 +1,6 @@
1
1
  caselawclient/Client.py,sha256=v8Zb7vZmoF3COJWtIzoJxTy8d3DLo-mlNH3MhfDL4hs,44931
2
2
  caselawclient/__init__.py,sha256=DY-caubLDQWWingSdsBWgovDNXh8KcnkI6kwz08eIFk,612
3
- caselawclient/client_helpers/__init__.py,sha256=mmPVwIxnR-KeelNIIMGjsTMzruK6j0X1YR_0H_RHnew,4798
3
+ caselawclient/client_helpers/__init__.py,sha256=Qo1bvNz6wq4-d9szsALYWTGrlg5mRyNccUJHOK_dsIM,5009
4
4
  caselawclient/client_helpers/search_helpers.py,sha256=R99HyRLeYHgsw2L3DOidEqlKLLvs6Tga5rKTuWQViig,1525
5
5
  caselawclient/content_hash.py,sha256=0cPC4OoABq0SC2wYFX9-24DodNigeOqksDxgxQH_hUA,2221
6
6
  caselawclient/errors.py,sha256=JC16fEGq_MRJX-_KFzfINCV2Cqx8o6OWOt3C16rQd84,3142
@@ -32,7 +32,7 @@ caselawclient/responses/search_result.py,sha256=l6wSruVJDLCT1JquDrUVk9TZ0Ic6w4Wl
32
32
  caselawclient/responses/xsl/search_match.xsl,sha256=4Sv--MrwBd7J48E9aI7jlFSXGlNi4dBqgzJ3bdMJ_ZU,1018
33
33
  caselawclient/search_parameters.py,sha256=nR-UC1aWZbdXzXBrVDaHECU4Ro8Zi4JZATtgrpAVsKY,3342
34
34
  caselawclient/types.py,sha256=0PsEsQzJOInpuwZ-Ydw0UpGns6jbHzlJhc-Ms28sqCU,2064
35
- caselawclient/xml_helpers.py,sha256=FEtE8gxaEZmcgua-Xu8awPmiOm9K58OSabEYVGpiVEY,493
35
+ caselawclient/xml_helpers.py,sha256=xCboRhhzezqh-VyoKBQwal5lwxv96vTMJyVFWJNN-ok,639
36
36
  caselawclient/xquery/break_judgment_checkout.xqy,sha256=rISzoBKxQKrP5ZRdCSoRqOXW8T_NDBSZRFjOXo_H3ns,220
37
37
  caselawclient/xquery/checkin_judgment.xqy,sha256=QeGqO3kL-q0UrjopCVU0lCbkwbyoc5SuNLYFAIbbyMg,197
38
38
  caselawclient/xquery/checkout_judgment.xqy,sha256=aRwVo4KXoEKXfXRZ6IrVfvh0pXK-7pFxVIgEyzE5DRY,385
@@ -80,7 +80,7 @@ caselawclient/xquery/validate_document.xqy,sha256=PgaDcnqCRJPIVqfmWsNlXmCLNKd21q
80
80
  caselawclient/xquery/xslt.xqy,sha256=w57wNijH3dkwHkpKeAxqjlghVflQwo8cq6jS_sm-erM,199
81
81
  caselawclient/xquery/xslt_transform.xqy,sha256=cccaFiGkCcvSfDv007UriZ3I4ak2nTLP1trRZdbOoS8,2462
82
82
  caselawclient/xquery_type_dicts.py,sha256=21V6PJ0a8lPZuwzQCWeHNo914hdCbCJtOvnqdHcTpKk,6383
83
- ds_caselaw_marklogic_api_client-34.0.0.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
84
- ds_caselaw_marklogic_api_client-34.0.0.dist-info/METADATA,sha256=1Y9daSrmdkheziHwxatUrnUuGlx4whYIcdURLgxibKU,4206
85
- ds_caselaw_marklogic_api_client-34.0.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
86
- ds_caselaw_marklogic_api_client-34.0.0.dist-info/RECORD,,
83
+ ds_caselaw_marklogic_api_client-34.0.1.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
84
+ ds_caselaw_marklogic_api_client-34.0.1.dist-info/METADATA,sha256=HA36beJz4OQedMNQ_c58IGx1RZX9GjM_h5JkOQm66Is,4206
85
+ ds_caselaw_marklogic_api_client-34.0.1.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
86
+ ds_caselaw_marklogic_api_client-34.0.1.dist-info/RECORD,,