ds-caselaw-marklogic-api-client 30.0.0__tar.gz → 31.0.1__tar.gz

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.

Files changed (86) hide show
  1. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/PKG-INFO +3 -3
  2. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/pyproject.toml +3 -3
  3. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/Client.py +1 -1
  4. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/factories.py +42 -3
  5. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/documents/__init__.py +19 -35
  6. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/documents/body.py +8 -8
  7. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/judgments.py +5 -0
  8. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/press_summaries.py +4 -0
  9. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/types.py +7 -0
  10. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/xslt_transform.xqy +1 -1
  11. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery_type_dicts.py +1 -1
  12. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/LICENSE.md +0 -0
  13. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/README.md +0 -0
  14. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/__init__.py +0 -0
  15. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/client_helpers/__init__.py +0 -0
  16. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/client_helpers/search_helpers.py +0 -0
  17. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/content_hash.py +0 -0
  18. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/errors.py +0 -0
  19. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/identifier_resolution.py +0 -0
  20. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/__init__.py +0 -0
  21. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/documents/exceptions.py +0 -0
  22. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/documents/statuses.py +0 -0
  23. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/documents/transforms/html.xsl +0 -0
  24. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/documents/xml.py +0 -0
  25. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/identifiers/__init__.py +0 -0
  26. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/identifiers/fclid.py +0 -0
  27. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/identifiers/neutral_citation.py +0 -0
  28. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/identifiers/press_summary_ncn.py +0 -0
  29. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/identifiers/unpacker.py +0 -0
  30. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/neutral_citation_mixin.py +0 -0
  31. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/utilities/__init__.py +0 -0
  32. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/utilities/aws.py +0 -0
  33. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/utilities/dates.py +0 -0
  34. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/models/utilities/move.py +0 -0
  35. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/py.typed +0 -0
  36. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/responses/__init__.py +0 -0
  37. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/responses/search_response.py +0 -0
  38. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/responses/search_result.py +0 -0
  39. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/responses/xsl/search_match.xsl +0 -0
  40. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/search_parameters.py +0 -0
  41. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xml_helpers.py +0 -0
  42. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/break_judgment_checkout.xqy +0 -0
  43. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/checkin_judgment.xqy +0 -0
  44. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/checkout_judgment.xqy +0 -0
  45. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/copy_document.xqy +0 -0
  46. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/delete_judgment.xqy +0 -0
  47. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/document_collections.xqy +0 -0
  48. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/document_exists.xqy +0 -0
  49. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_combined_stats_table.xqy +0 -0
  50. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_components_for_document.xqy +0 -0
  51. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_highest_enrichment_version.xqy +0 -0
  52. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_highest_parser_version.xqy +0 -0
  53. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_judgment.xqy +0 -0
  54. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_judgment_checkout_status.xqy +0 -0
  55. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_judgment_version.xqy +0 -0
  56. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_last_modified.xqy +0 -0
  57. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_next_document_sequence_number.xqy +0 -0
  58. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_pending_enrichment_for_version.xqy +0 -0
  59. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_pending_parse_for_version.xqy +0 -0
  60. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_properties_for_search_results.xqy +0 -0
  61. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_property.xqy +0 -0
  62. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_property_as_node.xqy +0 -0
  63. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_recently_enriched.xqy +0 -0
  64. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_recently_parsed.xqy +0 -0
  65. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_version_annotation.xqy +0 -0
  66. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/get_version_created.xqy +0 -0
  67. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/insert_document.xqy +0 -0
  68. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/list_judgment_versions.xqy +0 -0
  69. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/resolve_from_identifier_slug.xqy +0 -0
  70. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/resolve_from_identifier_value.xqy +0 -0
  71. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/set_boolean_property.xqy +0 -0
  72. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/set_metadata_citation.xqy +0 -0
  73. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/set_metadata_court.xqy +0 -0
  74. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/set_metadata_jurisdiction.xqy +0 -0
  75. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/set_metadata_name.xqy +0 -0
  76. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/set_metadata_this_uri.xqy +0 -0
  77. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/set_metadata_work_expression_date.xqy +0 -0
  78. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/set_property.xqy +0 -0
  79. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/set_property_as_node.xqy +0 -0
  80. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/update_document.xqy +0 -0
  81. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/update_locked_judgment.xqy +0 -0
  82. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/user_has_privilege.xqy +0 -0
  83. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/user_has_role.xqy +0 -0
  84. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/validate_all_documents.xqy +0 -0
  85. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/validate_document.xqy +0 -0
  86. {ds_caselaw_marklogic_api_client-30.0.0 → ds_caselaw_marklogic_api_client-31.0.1}/src/caselawclient/xquery/xslt.xqy +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ds-caselaw-marklogic-api-client
3
- Version: 30.0.0
3
+ Version: 31.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
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3.9
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Requires-Dist: boto3 (>=1.26.112,<2.0.0)
14
- Requires-Dist: certifi (>=2024.12.14,<2024.13.0)
14
+ Requires-Dist: certifi (>=2025.1.31,<2025.2.0)
15
15
  Requires-Dist: charset-normalizer (>=3.0.0,<4.0.0)
16
16
  Requires-Dist: django-environ (>=0.12.0)
17
17
  Requires-Dist: ds-caselaw-utils (>=2.0.0,<3.0.0)
@@ -21,7 +21,7 @@ Requires-Dist: memoization (>=0.4.0,<0.5.0)
21
21
  Requires-Dist: mypy-boto3-s3 (>=1.26.104,<2.0.0)
22
22
  Requires-Dist: mypy-boto3-sns (>=1.26.69,<2.0.0)
23
23
  Requires-Dist: python-dateutil (>=2.9.0-post.0,<3.0.0)
24
- Requires-Dist: pytz (>=2024.1,<2025.0)
24
+ Requires-Dist: pytz (>2024)
25
25
  Requires-Dist: requests (>=2.28.2,<3.0.0)
26
26
  Requires-Dist: requests-toolbelt (>=0.10.1,<1.1.0)
27
27
  Requires-Dist: saxonche (>=12.5.0,<13.0.0)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ds-caselaw-marklogic-api-client"
3
- version = "30.0.0"
3
+ version = "31.0.1"
4
4
  description = "An API client for interacting with the underlying data in Find Caselaw."
5
5
  authors = ["The National Archives"]
6
6
  homepage = "https://github.com/nationalarchives/ds-caselaw-custom-api-client"
@@ -12,7 +12,7 @@ packages = [
12
12
 
13
13
  [tool.poetry.dependencies]
14
14
  python = "^3.9"
15
- certifi = ">=2024.12.14,<2024.13.0"
15
+ certifi = ">=2025.1.31,<2025.2.0"
16
16
  charset-normalizer = "^3.0.0"
17
17
  django-environ = ">=0.12.0"
18
18
  idna = "^3.4"
@@ -25,7 +25,7 @@ boto3 = "^1.26.112"
25
25
  typing-extensions = "^4.7.1"
26
26
  mypy-boto3-s3 = "^1.26.104"
27
27
  mypy-boto3-sns = "^1.26.69"
28
- pytz = "^2024.1"
28
+ pytz = ">2024"
29
29
  python-dateutil = "^2.9.0-post.0"
30
30
  saxonche = "^12.5.0"
31
31
  sqids = "^0.5.0"
@@ -1222,7 +1222,7 @@ class MarklogicApiClient:
1222
1222
  warnings.warn(
1223
1223
  "resolve_from_identifier deprecated, use resolve_from_identifier_slug instead", DeprecationWarning
1224
1224
  )
1225
- return self.resolve_from_identifier(identifier_uri, published_only)
1225
+ return self.resolve_from_identifier_slug(identifier_uri, published_only)
1226
1226
 
1227
1227
  def resolve_from_identifier_value(
1228
1228
  self, identifier_value: str, published_only: bool = True
@@ -1,10 +1,12 @@
1
1
  import datetime
2
+ import json
2
3
  from typing import Any, Optional
3
4
  from unittest.mock import Mock
4
5
 
5
6
  from typing_extensions import TypeAlias
6
7
 
7
8
  from caselawclient.Client import MarklogicApiClient
9
+ from caselawclient.identifier_resolution import IdentifierResolution, IdentifierResolutions
8
10
  from caselawclient.models.documents import Document
9
11
  from caselawclient.models.documents.body import DocumentBody
10
12
  from caselawclient.models.judgments import Judgment
@@ -12,7 +14,16 @@ from caselawclient.models.press_summaries import PressSummary
12
14
  from caselawclient.responses.search_result import SearchResult, SearchResultMetadata
13
15
  from caselawclient.types import DocumentURIString
14
16
 
15
- DEFAULT_DOCUMENT_BODY_XML = "<akomantoso>This is some XML of a judgment.</akomantoso>"
17
+ DEFAULT_DOCUMENT_BODY_XML = """<akomaNtoso xmlns="http://docs.oasis-open.org/legaldocml/ns/akn/3.0" xmlns:uk="https://caselaw.nationalarchives.gov.uk/akn">
18
+ <judgment name="decision">
19
+ <meta/><header/>
20
+ <judgmentBody>
21
+ <decision>
22
+ <p>This is a document.</p>
23
+ </decision>
24
+ </judgmentBody>
25
+ </judgment>
26
+ </akomaNtoso>"""
16
27
 
17
28
 
18
29
  class DocumentBodyFactory:
@@ -56,7 +67,6 @@ class DocumentFactory:
56
67
  def build(
57
68
  cls,
58
69
  uri: DocumentURIString = DocumentURIString("test/2023/123"),
59
- html: str = "<p>This is a judgment.</p>",
60
70
  api_client: Optional[MarklogicApiClient] = None,
61
71
  **kwargs: Any,
62
72
  ) -> target_class:
@@ -66,7 +76,6 @@ class DocumentFactory:
66
76
  api_client.get_property_as_node.return_value = None
67
77
 
68
78
  document = cls.target_class(uri, api_client=api_client)
69
- document.content_as_html = Mock(return_value=html) # type: ignore[method-assign]
70
79
  document.body = kwargs.pop("body") if "body" in kwargs else DocumentBodyFactory.build()
71
80
 
72
81
  for param_name, default_value in cls.PARAMS_MAP.items():
@@ -133,3 +142,33 @@ class SearchResultFactory(SimpleFactory):
133
142
  "metadata": SearchResultMetadataFactory.build(),
134
143
  "is_failure": False,
135
144
  }
145
+
146
+
147
+ class IdentifierResolutionFactory:
148
+ @classmethod
149
+ def build(
150
+ self,
151
+ resolution_uuid: Optional[str] = None,
152
+ document_uri: Optional[str] = None,
153
+ identifier_slug: Optional[str] = None,
154
+ published: Optional[bool] = True,
155
+ namespace: Optional[str] = None,
156
+ value: Optional[str] = None,
157
+ ) -> IdentifierResolution:
158
+ raw_resolution = {
159
+ "documents.compiled_url_slugs.identifier_uuid": resolution_uuid or "24b9a384-8bcf-4f20-996a-5c318f8dc657",
160
+ "documents.compiled_url_slugs.document_uri": document_uri or "/ewca/civ/2003/547.xml",
161
+ "documents.compiled_url_slugs.identifier_slug": identifier_slug or "ewca/civ/2003/54721",
162
+ "documents.compiled_url_slugs.document_published": "true" if published else "false",
163
+ "documents.compiled_url_slugs.identifier_namespace": namespace or "ukncn",
164
+ "documents.compiled_url_slugs.identifier_value": value or "[2003] EWCA 54721 (Civ)",
165
+ }
166
+ return IdentifierResolution.from_marklogic_output(json.dumps(raw_resolution))
167
+
168
+
169
+ class IdentifierResolutionsFactory:
170
+ @classmethod
171
+ def build(self, resolutions: Optional[list[IdentifierResolution]] = None) -> IdentifierResolutions:
172
+ if resolutions is None:
173
+ resolutions = [IdentifierResolutionFactory.build()]
174
+ return IdentifierResolutions(resolutions)
@@ -6,15 +6,14 @@ from typing import TYPE_CHECKING, Any, Optional
6
6
  from ds_caselaw_utils import courts
7
7
  from ds_caselaw_utils.courts import CourtNotFoundException
8
8
  from ds_caselaw_utils.types import NeutralCitationString
9
- from lxml import html as html_parser
10
9
  from requests_toolbelt.multipart import decoder
11
10
 
12
11
  from caselawclient.errors import (
13
12
  DocumentNotFoundError,
14
- GatewayTimeoutError,
15
13
  NotSupportedOnVersion,
16
14
  OnlySupportedOnVersion,
17
15
  )
16
+ from caselawclient.identifier_resolution import IdentifierResolutions
18
17
  from caselawclient.models.identifiers import Identifier
19
18
  from caselawclient.models.identifiers.fclid import FindCaseLawIdentifier, FindCaseLawIdentifierSchema
20
19
  from caselawclient.models.identifiers.unpacker import unpack_all_identifiers_from_etree
@@ -252,39 +251,6 @@ class Document:
252
251
  "Is this document a potentially historic version of a document, or is it the main document itself?"
253
252
  return extract_version(self.uri) != 0
254
253
 
255
- def content_as_html(
256
- self,
257
- version_uri: Optional[DocumentURIString] = None,
258
- query: Optional[str] = None,
259
- ) -> str:
260
- try:
261
- results = self.api_client.eval_xslt(
262
- self.uri,
263
- version_uri,
264
- show_unpublished=True,
265
- query=query,
266
- )
267
- multipart_data = decoder.MultipartDecoder.from_response(results)
268
- return str(multipart_data.parts[0].text)
269
- except GatewayTimeoutError as e:
270
- if query is not None:
271
- warnings.warn(
272
- (
273
- "Gateway timeout when getting content with query"
274
- "highlighting for document %s, version %s, and query"
275
- '"%s", falling back to unhighlighted content...'
276
- )
277
- % (self.uri, version_uri, query),
278
- GatewayTimeoutGettingHTMLWithQuery,
279
- )
280
- return self.content_as_html(version_uri)
281
- raise e
282
-
283
- def number_of_mentions(self, query: str) -> int:
284
- html = self.content_as_html(query=query)
285
- tree = html_parser.fromstring(html.encode("utf-8"))
286
- return len(tree.findall(".//mark"))
287
-
288
254
  @cached_property
289
255
  def is_failure(self) -> bool:
290
256
  """
@@ -529,3 +495,21 @@ class Document:
529
495
  return getattr(self.body, name)
530
496
  except Exception:
531
497
  raise AttributeError(f"Neither 'Document' nor 'DocumentBody' objects have an attribute '{name}'")
498
+
499
+ def linked_document_resolutions(self, namespaces: list[str], only_published: bool = True) -> IdentifierResolutions:
500
+ """Get documents which share the same neutral citation as this document."""
501
+ if not hasattr(self, "neutral_citation") or not self.neutral_citation:
502
+ return IdentifierResolutions([])
503
+
504
+ resolutions = self.api_client.resolve_from_identifier_value(self.neutral_citation)
505
+ if only_published:
506
+ resolutions = resolutions.published()
507
+
508
+ # only documents which aren't this one and have a right namespace
509
+ return IdentifierResolutions(
510
+ [
511
+ resolution
512
+ for resolution in resolutions
513
+ if resolution.document_uri != self.uri.as_marklogic() and resolution.identifier_namespace in namespaces
514
+ ]
515
+ )
@@ -3,7 +3,6 @@ import os
3
3
  import warnings
4
4
  from functools import cache, cached_property
5
5
  from typing import Optional
6
- from xml.etree.ElementTree import Element
7
6
 
8
7
  import pytz
9
8
  from ds_caselaw_utils.types import CourtCode
@@ -128,13 +127,14 @@ class DocumentBody:
128
127
  def has_content(self) -> bool:
129
128
  """If we do not have a word document, the XML will not contain
130
129
  the contents of the judgment, but will contain a preamble."""
131
-
132
- def stripped_tag_text(tag: Element) -> str:
133
- return "".join(tag.itertext()).strip()
134
-
135
- header = self._xml.xml_as_tree.xpath("//akn:header", namespaces=DEFAULT_NAMESPACES)[0]
136
- content = self._xml.xml_as_tree.xpath("//akn:judgmentBody", namespaces=DEFAULT_NAMESPACES)[0]
137
- return not (stripped_tag_text(header) == "" and stripped_tag_text(content) == "")
130
+ trailing_tags = self._xml.xml_as_tree.xpath("//*[preceding::akn:meta]", namespaces=DEFAULT_NAMESPACES)
131
+ for tag in trailing_tags:
132
+ if tag.tail and tag.tail.strip():
133
+ return True
134
+ if tag.text and tag.text.strip():
135
+ return True
136
+
137
+ return False
138
138
 
139
139
  @cache
140
140
  def content_as_html(self, image_base_url: Optional[str] = None) -> Optional[str]:
@@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, Any, Optional
5
5
  from ds_caselaw_utils.types import NeutralCitationString
6
6
 
7
7
  from caselawclient.errors import DocumentNotFoundError
8
+ from caselawclient.identifier_resolution import IdentifierResolutions
8
9
  from caselawclient.models.neutral_citation_mixin import NeutralCitationMixin
9
10
 
10
11
  if TYPE_CHECKING:
@@ -51,3 +52,7 @@ class Judgment(NeutralCitationMixin, Document):
51
52
  return PressSummary(uri, self.api_client)
52
53
  except DocumentNotFoundError:
53
54
  return None
55
+
56
+ @cached_property
57
+ def linked_press_summaries(self, only_published: bool = True) -> "IdentifierResolutions":
58
+ return self.linked_document_resolutions(["uksummaryofncn"], only_published)
@@ -7,6 +7,7 @@ from typing import TYPE_CHECKING, Any, Optional
7
7
  from ds_caselaw_utils.types import NeutralCitationString
8
8
 
9
9
  from caselawclient.errors import DocumentNotFoundError
10
+ from caselawclient.identifier_resolution import IdentifierResolutions
10
11
  from caselawclient.models.neutral_citation_mixin import NeutralCitationMixin
11
12
  from caselawclient.types import DocumentURIString
12
13
 
@@ -51,3 +52,6 @@ class PressSummary(NeutralCitationMixin, Document):
51
52
  return Judgment(uri, self.api_client)
52
53
  except DocumentNotFoundError:
53
54
  return None
55
+
56
+ def linked_judgments(self, only_published: bool = True) -> "IdentifierResolutions":
57
+ return self.linked_document_resolutions(["ukncn"], only_published)
@@ -2,6 +2,10 @@ class InvalidDocumentURIException(Exception):
2
2
  """The document URI is not valid."""
3
3
 
4
4
 
5
+ class MarkLogicDocumentURIString(str):
6
+ pass
7
+
8
+
5
9
  class DocumentURIString(str):
6
10
  """
7
11
  This class checks that the string is actually a valid Document URI on creation. It does _not_ manipulate the string.
@@ -22,3 +26,6 @@ class DocumentURIString(str):
22
26
 
23
27
  # If everything is good, return as usual
24
28
  return str.__new__(cls, content)
29
+
30
+ def as_marklogic(self) -> MarkLogicDocumentURIString:
31
+ return MarkLogicDocumentURIString(f"/{self}.xml")
@@ -28,7 +28,7 @@ let $number_marks_xslt := (
28
28
  </xsl:template>
29
29
  <xsl:template match="mark">
30
30
  <xsl:copy>
31
- <xsl:copy-of select="@*" />
31
+ <xsl:copy-of select="*" />
32
32
  <xsl:attribute name="id">
33
33
  <xsl:text>mark_</xsl:text>
34
34
  <xsl:value-of select="count(preceding::mark)"/>
@@ -8,8 +8,8 @@ checks. They are used to enforce appropriately typed variables being passed in t
8
8
 
9
9
  from typing import Any, NewType, Optional, TypedDict
10
10
  from caselawclient.types import DocumentURIString
11
+ from caselawclient.types import MarkLogicDocumentURIString as MarkLogicDocumentURIString
11
12
 
12
- MarkLogicDocumentURIString = NewType("MarkLogicDocumentURIString", str)
13
13
  MarkLogicDocumentVersionURIString = NewType("MarkLogicDocumentVersionURIString", MarkLogicDocumentURIString)
14
14
 
15
15
  MarkLogicPrivilegeURIString = NewType("MarkLogicPrivilegeURIString", str)