ds-caselaw-marklogic-api-client 36.0.1__py3-none-any.whl → 37.0.0__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.
@@ -1,4 +1,5 @@
1
1
  import datetime
2
+ import os
2
3
  import warnings
3
4
  from functools import cached_property
4
5
  from typing import TYPE_CHECKING, Any, Optional
@@ -529,3 +530,7 @@ class Document:
529
530
  Document(resolution.document_uri.as_document_uri(), api_client=self.api_client)
530
531
  for resolution in resolutions
531
532
  ]
533
+
534
+ def content_as_html(self) -> str | None:
535
+ xlst_image_location = os.getenv("XSLT_IMAGE_LOCATION", "")
536
+ return self.body.content_html(f"{xlst_image_location}/{self.uri}")
@@ -137,8 +137,11 @@ class DocumentBody:
137
137
  return False
138
138
 
139
139
  @cache
140
- def content_as_html(self, image_base_url: Optional[str] = None) -> Optional[str]:
140
+ def content_html(self, image_prefix: str) -> Optional[str]:
141
141
  """Convert the XML representation of the Document into HTML for rendering."""
142
+ """This used to be called content_as_html but we have changed the parameter passed to it from the
143
+ domain of the assets to the path in which the assets are stored (from assets to assets/d-a1b2c3)
144
+ and made the image_prefix mandatory"""
142
145
  if not self.has_content:
143
146
  return None
144
147
 
@@ -150,8 +153,8 @@ class DocumentBody:
150
153
 
151
154
  executable = xslt_processor.compile_stylesheet(stylesheet_file=html_xslt_location)
152
155
 
153
- if image_base_url:
154
- executable.set_parameter("image-base", proc.make_string_value(image_base_url))
156
+ if image_prefix:
157
+ executable.set_parameter("image-prefix", proc.make_string_value(image_prefix))
155
158
 
156
159
  return str(executable.transform_to_string(xdm_node=document))
157
160
 
@@ -13,7 +13,7 @@
13
13
  <xsl:strip-space elements="*" />
14
14
  <xsl:preserve-space elements="p block num heading span a courtType date docDate docTitle docketNumber judge lawyer location neutralCitation party role time" />
15
15
 
16
- <xsl:param name="image-base" as="xs:string" select="'https://assets.caselaw.nationalarchives.gov.uk/'" />
16
+ <xsl:param name="image-prefix" as="xs:string" />
17
17
 
18
18
  <xsl:function name="uk:link-is-supported" as="xs:boolean">
19
19
  <xsl:param name="href" as="attribute()?" />
@@ -741,7 +741,7 @@
741
741
  </xsl:template>
742
742
  <xsl:template match="img/@src">
743
743
  <xsl:attribute name="src">
744
- <xsl:sequence select="concat($image-base, $doc-id, '/', .)" />
744
+ <xsl:sequence select="concat($image-prefix, '/', .)" />
745
745
  </xsl:attribute>
746
746
  </xsl:template>
747
747
 
@@ -8,7 +8,7 @@ from caselawclient.types import DocumentIdentifierSlug
8
8
  from . import Identifier, IdentifierSchema
9
9
  from .exceptions import IdentifierValidationException
10
10
 
11
- VALID_NCN_PATTERN = re.compile(r"(^\[([0-9]{4})\] ([a-zA-Z]+)(?: ([a-zA-Z]+))? ([0-9]+)(?: \(([a-zA-Z]+)\))?$)")
11
+ VALID_NCN_PATTERN = re.compile(r"(^\[([0-9]{4})\] ([a-zA-Z]+)(?: ([a-zA-Z]+))? ([0-9]+)(?: \(([a-zA-Z0-9]+)\))?$)")
12
12
  """
13
13
  This is a catch-all pattern for anything which looks like a Neutral Citation, even if the court itself isn't valid. Checking that an NCN is plausibly correct is handled elsewhere.
14
14
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ds-caselaw-marklogic-api-client
3
- Version: 36.0.1
3
+ Version: 37.0.0
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
@@ -7,16 +7,16 @@ caselawclient/errors.py,sha256=JC16fEGq_MRJX-_KFzfINCV2Cqx8o6OWOt3C16rQd84,3142
7
7
  caselawclient/factories.py,sha256=MiOwS44w6zCGZEfYdZT5x5RL8CeBIvUmiBYYWuNbC-0,6942
8
8
  caselawclient/identifier_resolution.py,sha256=B5I1sD7o7YjzsXMECjbKjgiGLDda5bGhejsJ-lYpTIg,2429
9
9
  caselawclient/models/__init__.py,sha256=kd23EUpvaC7aLHdgk8farqKAQEx3lf7RvNT2jEatvlg,68
10
- caselawclient/models/documents/__init__.py,sha256=7U5oN2b8JZV9sFSYglBg2K7fKKQgDjTVU5FT22URx7U,19043
11
- caselawclient/models/documents/body.py,sha256=mhPOV1cOF3RJr69UzNPlo1KrzePaj7KDPYi1exP06L0,5880
10
+ caselawclient/models/documents/__init__.py,sha256=TatleqbzvvNYa9el9NauiB0g9b7VhmdRSzL-tskrqXA,19241
11
+ caselawclient/models/documents/body.py,sha256=IVcuSbgA7SvCvii_VE8MZy_54enDZY8VPoESkUDgfKU,6114
12
12
  caselawclient/models/documents/exceptions.py,sha256=Mz1P8uNqf5w6uLnRwJt6xK7efsVqtd5VA-WXUUH7QLk,285
13
13
  caselawclient/models/documents/statuses.py,sha256=Cp4dTQmJOtsU41EJcxy5dV1841pGD2PNWH0VrkDEv4Q,579
14
- caselawclient/models/documents/transforms/html.xsl,sha256=oSSO-IBX4qLiSWexQYmWJfGNevF09aCBx4D1NYqXxpo,38322
14
+ caselawclient/models/documents/transforms/html.xsl,sha256=XyUQLFcJ7_GwthWQ6ShU0bmzrgpl7xDFU-U8VLgOvEs,38258
15
15
  caselawclient/models/documents/xml.py,sha256=HlmPb63lLMnySSOLP4iexcAyQiLByKBZtTd25f8sY8M,1268
16
16
  caselawclient/models/identifiers/__init__.py,sha256=_iAsx_e-Rxq3ED3TQQ5Vg1ZNnQn6AZQK8QCvHSFhdGg,6848
17
17
  caselawclient/models/identifiers/exceptions.py,sha256=ckVsjPzLuTXkbd7KZRJXoxcltQCXPGL2rMyYwE5orgg,177
18
18
  caselawclient/models/identifiers/fclid.py,sha256=Gq0G0eLdUH3j7VybluqJGVcHV3Y-hpjty1OdR91dI5Q,1453
19
- caselawclient/models/identifiers/neutral_citation.py,sha256=cgB1PO44ra8dKsYGq9_g53be8T1mQatq9Hh_DN5DVg0,2868
19
+ caselawclient/models/identifiers/neutral_citation.py,sha256=mFc-nYDIkLf5fM2eTSBnBigVgxuDcUF2HuMwQYEYeXY,2871
20
20
  caselawclient/models/identifiers/press_summary_ncn.py,sha256=CKhNTnO6pfriS4Sg-gt0Pf0fRhH53Uf0flULPncJWM4,762
21
21
  caselawclient/models/identifiers/unpacker.py,sha256=fKfiuTKaN-71e40PV8BC9PueKjwgfX9Xw3IVdy8mkqg,2299
22
22
  caselawclient/models/judgments.py,sha256=r40irgdEID-NeSNLm3OUdUBznMpRSwjD2SJrGlBgP8o,2208
@@ -82,7 +82,7 @@ caselawclient/xquery/validate_document.xqy,sha256=PgaDcnqCRJPIVqfmWsNlXmCLNKd21q
82
82
  caselawclient/xquery/xslt.xqy,sha256=w57wNijH3dkwHkpKeAxqjlghVflQwo8cq6jS_sm-erM,199
83
83
  caselawclient/xquery/xslt_transform.xqy,sha256=cccaFiGkCcvSfDv007UriZ3I4ak2nTLP1trRZdbOoS8,2462
84
84
  caselawclient/xquery_type_dicts.py,sha256=21V6PJ0a8lPZuwzQCWeHNo914hdCbCJtOvnqdHcTpKk,6383
85
- ds_caselaw_marklogic_api_client-36.0.1.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
86
- ds_caselaw_marklogic_api_client-36.0.1.dist-info/METADATA,sha256=-rEbiJvBPiF_VGPYSsjJoJFlz5m2tJyEQrodrQfF0KA,4206
87
- ds_caselaw_marklogic_api_client-36.0.1.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
88
- ds_caselaw_marklogic_api_client-36.0.1.dist-info/RECORD,,
85
+ ds_caselaw_marklogic_api_client-37.0.0.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
86
+ ds_caselaw_marklogic_api_client-37.0.0.dist-info/METADATA,sha256=0v9UC-LN07GEm7ci1s3hPeqjiHpJUbMdqpLloSGJzA0,4206
87
+ ds_caselaw_marklogic_api_client-37.0.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
88
+ ds_caselaw_marklogic_api_client-37.0.0.dist-info/RECORD,,