ds-caselaw-marklogic-api-client 31.0.1__tar.gz → 31.2.0__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.
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/PKG-INFO +1 -1
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/pyproject.toml +1 -1
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/Client.py +6 -10
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/factories.py +14 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/identifier_resolution.py +5 -5
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/documents/__init__.py +21 -2
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/identifiers/__init__.py +5 -3
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/identifiers/fclid.py +4 -2
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/identifiers/neutral_citation.py +4 -2
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/identifiers/press_summary_ncn.py +4 -2
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/types.py +30 -1
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/resolve_from_identifier_slug.xqy +2 -3
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery_type_dicts.py +3 -3
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/LICENSE.md +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/README.md +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/client_helpers/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/client_helpers/search_helpers.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/content_hash.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/errors.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/documents/body.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/documents/exceptions.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/documents/statuses.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/documents/transforms/html.xsl +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/documents/xml.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/identifiers/unpacker.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/judgments.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/neutral_citation_mixin.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/press_summaries.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/utilities/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/utilities/aws.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/utilities/dates.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/models/utilities/move.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/py.typed +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/responses/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/responses/search_response.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/responses/search_result.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/responses/xsl/search_match.xsl +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/search_parameters.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xml_helpers.py +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/break_judgment_checkout.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/checkin_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/checkout_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/copy_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/delete_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/document_collections.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/document_exists.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_combined_stats_table.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_components_for_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_highest_enrichment_version.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_highest_parser_version.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_judgment_checkout_status.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_judgment_version.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_last_modified.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_next_document_sequence_number.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_pending_enrichment_for_version.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_pending_parse_for_version.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_properties_for_search_results.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_property.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_property_as_node.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_recently_enriched.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_recently_parsed.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_version_annotation.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/get_version_created.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/insert_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/list_judgment_versions.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/resolve_from_identifier_value.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/set_boolean_property.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/set_metadata_citation.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/set_metadata_court.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/set_metadata_jurisdiction.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/set_metadata_name.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/set_metadata_this_uri.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/set_metadata_work_expression_date.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/set_property.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/set_property_as_node.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/update_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/update_locked_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/user_has_privilege.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/user_has_role.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/validate_all_documents.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/validate_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/xslt.xqy +0 -0
- {ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/src/caselawclient/xquery/xslt_transform.xqy +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ds-caselaw-marklogic-api-client
|
|
3
|
-
Version: 31.0
|
|
3
|
+
Version: 31.2.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
|
{ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/pyproject.toml
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "ds-caselaw-marklogic-api-client"
|
|
3
|
-
version = "31.0
|
|
3
|
+
version = "31.2.0"
|
|
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"
|
|
@@ -30,7 +30,7 @@ from caselawclient.models.judgments import Judgment
|
|
|
30
30
|
from caselawclient.models.press_summaries import PressSummary
|
|
31
31
|
from caselawclient.models.utilities import move
|
|
32
32
|
from caselawclient.search_parameters import SearchParameters
|
|
33
|
-
from caselawclient.types import DocumentURIString
|
|
33
|
+
from caselawclient.types import DocumentIdentifierSlug, DocumentIdentifierValue, DocumentURIString
|
|
34
34
|
from caselawclient.xquery_type_dicts import (
|
|
35
35
|
MarkLogicDocumentURIString,
|
|
36
36
|
MarkLogicDocumentVersionURIString,
|
|
@@ -1203,11 +1203,13 @@ class MarklogicApiClient:
|
|
|
1203
1203
|
|
|
1204
1204
|
return results
|
|
1205
1205
|
|
|
1206
|
-
def resolve_from_identifier_slug(
|
|
1206
|
+
def resolve_from_identifier_slug(
|
|
1207
|
+
self, identifier_slug: DocumentIdentifierSlug, published_only: bool = True
|
|
1208
|
+
) -> IdentifierResolutions:
|
|
1207
1209
|
"""Given a PUI/EUI url, look up the precomputed slug and return the
|
|
1208
1210
|
MarkLogic document URIs which match that slug. Multiple returns should be anticipated"""
|
|
1209
1211
|
vars: query_dicts.ResolveFromIdentifierSlugDict = {
|
|
1210
|
-
"
|
|
1212
|
+
"identifier_slug": identifier_slug,
|
|
1211
1213
|
"published_only": int(published_only),
|
|
1212
1214
|
}
|
|
1213
1215
|
raw_results: list[str] = get_multipart_strings_from_marklogic_response(
|
|
@@ -1218,14 +1220,8 @@ class MarklogicApiClient:
|
|
|
1218
1220
|
)
|
|
1219
1221
|
return IdentifierResolutions.from_marklogic_output(raw_results)
|
|
1220
1222
|
|
|
1221
|
-
def resolve_from_identifier(self, identifier_uri: str, published_only: bool = True) -> IdentifierResolutions:
|
|
1222
|
-
warnings.warn(
|
|
1223
|
-
"resolve_from_identifier deprecated, use resolve_from_identifier_slug instead", DeprecationWarning
|
|
1224
|
-
)
|
|
1225
|
-
return self.resolve_from_identifier_slug(identifier_uri, published_only)
|
|
1226
|
-
|
|
1227
1223
|
def resolve_from_identifier_value(
|
|
1228
|
-
self, identifier_value:
|
|
1224
|
+
self, identifier_value: DocumentIdentifierValue, published_only: bool = True
|
|
1229
1225
|
) -> IdentifierResolutions:
|
|
1230
1226
|
"""Given a PUI/EUI url, look up the precomputed slug and return the
|
|
1231
1227
|
MarkLogic document URIs which match that slug. Multiple returns should be anticipated"""
|
|
@@ -9,6 +9,8 @@ from caselawclient.Client import MarklogicApiClient
|
|
|
9
9
|
from caselawclient.identifier_resolution import IdentifierResolution, IdentifierResolutions
|
|
10
10
|
from caselawclient.models.documents import Document
|
|
11
11
|
from caselawclient.models.documents.body import DocumentBody
|
|
12
|
+
from caselawclient.models.identifiers import Identifier
|
|
13
|
+
from caselawclient.models.identifiers.fclid import FindCaseLawIdentifier
|
|
12
14
|
from caselawclient.models.judgments import Judgment
|
|
13
15
|
from caselawclient.models.press_summaries import PressSummary
|
|
14
16
|
from caselawclient.responses.search_result import SearchResult, SearchResultMetadata
|
|
@@ -68,8 +70,12 @@ class DocumentFactory:
|
|
|
68
70
|
cls,
|
|
69
71
|
uri: DocumentURIString = DocumentURIString("test/2023/123"),
|
|
70
72
|
api_client: Optional[MarklogicApiClient] = None,
|
|
73
|
+
identifiers: Optional[list[Identifier]] = None,
|
|
71
74
|
**kwargs: Any,
|
|
72
75
|
) -> target_class:
|
|
76
|
+
def _fake_linked_documents(*args: Any, **kwargs: Any) -> list["Document"]:
|
|
77
|
+
return [document]
|
|
78
|
+
|
|
73
79
|
if not api_client:
|
|
74
80
|
api_client = Mock(spec=MarklogicApiClient)
|
|
75
81
|
api_client.get_judgment_xml_bytestring.return_value = DEFAULT_DOCUMENT_BODY_XML.encode(encoding="utf-8")
|
|
@@ -78,6 +84,14 @@ class DocumentFactory:
|
|
|
78
84
|
document = cls.target_class(uri, api_client=api_client)
|
|
79
85
|
document.body = kwargs.pop("body") if "body" in kwargs else DocumentBodyFactory.build()
|
|
80
86
|
|
|
87
|
+
if identifiers is None:
|
|
88
|
+
document.identifiers.add(FindCaseLawIdentifier(value="a1b2c3"))
|
|
89
|
+
else:
|
|
90
|
+
for identifier in identifiers:
|
|
91
|
+
document.identifiers.add(identifier)
|
|
92
|
+
|
|
93
|
+
setattr(document, "linked_documents", _fake_linked_documents)
|
|
94
|
+
|
|
81
95
|
for param_name, default_value in cls.PARAMS_MAP.items():
|
|
82
96
|
value = kwargs.get(param_name, default_value)
|
|
83
97
|
setattr(document, param_name, value)
|
|
@@ -3,7 +3,7 @@ from typing import NamedTuple
|
|
|
3
3
|
|
|
4
4
|
from caselawclient.models.identifiers import Identifier
|
|
5
5
|
from caselawclient.models.identifiers.unpacker import IDENTIFIER_NAMESPACE_MAP
|
|
6
|
-
from caselawclient.types import
|
|
6
|
+
from caselawclient.types import DocumentIdentifierSlug, DocumentIdentifierValue
|
|
7
7
|
from caselawclient.xquery_type_dicts import MarkLogicDocumentURIString
|
|
8
8
|
|
|
9
9
|
|
|
@@ -31,9 +31,9 @@ class IdentifierResolution(NamedTuple):
|
|
|
31
31
|
|
|
32
32
|
identifier_uuid: str
|
|
33
33
|
document_uri: MarkLogicDocumentURIString
|
|
34
|
-
identifier_slug:
|
|
34
|
+
identifier_slug: DocumentIdentifierSlug
|
|
35
35
|
document_published: bool
|
|
36
|
-
identifier_value:
|
|
36
|
+
identifier_value: DocumentIdentifierValue
|
|
37
37
|
identifier_namespace: str
|
|
38
38
|
identifier_type: type[Identifier]
|
|
39
39
|
|
|
@@ -44,9 +44,9 @@ class IdentifierResolution(NamedTuple):
|
|
|
44
44
|
return IdentifierResolution(
|
|
45
45
|
identifier_uuid=row["documents.compiled_url_slugs.identifier_uuid"],
|
|
46
46
|
document_uri=MarkLogicDocumentURIString(row["documents.compiled_url_slugs.document_uri"]),
|
|
47
|
-
identifier_slug=
|
|
47
|
+
identifier_slug=DocumentIdentifierSlug(row["documents.compiled_url_slugs.identifier_slug"]),
|
|
48
48
|
document_published=row["documents.compiled_url_slugs.document_published"] == "true",
|
|
49
|
-
identifier_value=row["documents.compiled_url_slugs.identifier_value"],
|
|
49
|
+
identifier_value=DocumentIdentifierValue(row["documents.compiled_url_slugs.identifier_value"]),
|
|
50
50
|
identifier_namespace=identifier_namespace,
|
|
51
51
|
identifier_type=IDENTIFIER_NAMESPACE_MAP[identifier_namespace],
|
|
52
52
|
)
|
|
@@ -161,7 +161,19 @@ class Document:
|
|
|
161
161
|
"""
|
|
162
162
|
:return: The absolute, public URI at which a copy of this document can be found
|
|
163
163
|
"""
|
|
164
|
-
return f"https://caselaw.nationalarchives.gov.uk/{self.
|
|
164
|
+
return f"https://caselaw.nationalarchives.gov.uk/{self.slug}"
|
|
165
|
+
|
|
166
|
+
@cached_property
|
|
167
|
+
def slug(self) -> str:
|
|
168
|
+
"""
|
|
169
|
+
:return: The best public-facing URL for the judgment, which is the slug
|
|
170
|
+
of the most-preferred identifier, which should either be an NCN or fclid.
|
|
171
|
+
"""
|
|
172
|
+
preferred_identifier = self.identifiers.preferred()
|
|
173
|
+
if preferred_identifier:
|
|
174
|
+
return preferred_identifier.url_slug
|
|
175
|
+
msg = f"No preferred identifier exists for {self.uri}"
|
|
176
|
+
raise RuntimeError(msg)
|
|
165
177
|
|
|
166
178
|
@cached_property
|
|
167
179
|
def is_published(self) -> bool:
|
|
@@ -497,7 +509,7 @@ class Document:
|
|
|
497
509
|
raise AttributeError(f"Neither 'Document' nor 'DocumentBody' objects have an attribute '{name}'")
|
|
498
510
|
|
|
499
511
|
def linked_document_resolutions(self, namespaces: list[str], only_published: bool = True) -> IdentifierResolutions:
|
|
500
|
-
"""Get
|
|
512
|
+
"""Get document resolutions which share the same neutral citation as this document."""
|
|
501
513
|
if not hasattr(self, "neutral_citation") or not self.neutral_citation:
|
|
502
514
|
return IdentifierResolutions([])
|
|
503
515
|
|
|
@@ -513,3 +525,10 @@ class Document:
|
|
|
513
525
|
if resolution.document_uri != self.uri.as_marklogic() and resolution.identifier_namespace in namespaces
|
|
514
526
|
]
|
|
515
527
|
)
|
|
528
|
+
|
|
529
|
+
def linked_documents(self, namespaces: list[str], only_published: bool = True) -> list["Document"]:
|
|
530
|
+
resolutions = self.linked_document_resolutions(namespaces=namespaces, only_published=only_published)
|
|
531
|
+
return [
|
|
532
|
+
Document(resolution.document_uri.as_document_uri(), api_client=self.api_client)
|
|
533
|
+
for resolution in resolutions
|
|
534
|
+
]
|
|
@@ -4,6 +4,8 @@ from uuid import uuid4
|
|
|
4
4
|
|
|
5
5
|
from lxml import etree
|
|
6
6
|
|
|
7
|
+
from caselawclient.types import DocumentIdentifierSlug, DocumentIdentifierValue
|
|
8
|
+
|
|
7
9
|
IDENTIFIER_PACKABLE_ATTRIBUTES: list[str] = [
|
|
8
10
|
"uuid",
|
|
9
11
|
"value",
|
|
@@ -60,7 +62,7 @@ class IdentifierSchema(ABC):
|
|
|
60
62
|
|
|
61
63
|
@classmethod
|
|
62
64
|
@abstractmethod
|
|
63
|
-
def compile_identifier_url_slug(cls, value: str) ->
|
|
65
|
+
def compile_identifier_url_slug(cls, value: str) -> DocumentIdentifierSlug:
|
|
64
66
|
"""Convert an identifier into a precompiled URL slug."""
|
|
65
67
|
pass
|
|
66
68
|
|
|
@@ -71,7 +73,7 @@ class Identifier(ABC):
|
|
|
71
73
|
schema: type[IdentifierSchema]
|
|
72
74
|
|
|
73
75
|
uuid: str
|
|
74
|
-
value:
|
|
76
|
+
value: DocumentIdentifierValue
|
|
75
77
|
|
|
76
78
|
def __init_subclass__(cls: type["Identifier"], **kwargs: Any) -> None:
|
|
77
79
|
"""Ensure that subclasses have the required attributes set."""
|
|
@@ -87,7 +89,7 @@ class Identifier(ABC):
|
|
|
87
89
|
return self.value
|
|
88
90
|
|
|
89
91
|
def __init__(self, value: str, uuid: Optional[str] = None) -> None:
|
|
90
|
-
self.value = value
|
|
92
|
+
self.value = DocumentIdentifierValue(value)
|
|
91
93
|
if uuid:
|
|
92
94
|
self.uuid = uuid
|
|
93
95
|
else:
|
|
@@ -3,6 +3,8 @@ from typing import TYPE_CHECKING
|
|
|
3
3
|
|
|
4
4
|
from sqids import Sqids
|
|
5
5
|
|
|
6
|
+
from caselawclient.types import DocumentIdentifierSlug
|
|
7
|
+
|
|
6
8
|
from . import Identifier, IdentifierSchema
|
|
7
9
|
|
|
8
10
|
if TYPE_CHECKING:
|
|
@@ -35,8 +37,8 @@ class FindCaseLawIdentifierSchema(IdentifierSchema):
|
|
|
35
37
|
return bool(VALID_FCLID_PATTERN.match(value))
|
|
36
38
|
|
|
37
39
|
@classmethod
|
|
38
|
-
def compile_identifier_url_slug(cls, value: str) ->
|
|
39
|
-
return "tna." + value
|
|
40
|
+
def compile_identifier_url_slug(cls, value: str) -> DocumentIdentifierSlug:
|
|
41
|
+
return DocumentIdentifierSlug("tna." + value)
|
|
40
42
|
|
|
41
43
|
@classmethod
|
|
42
44
|
def mint(cls, api_client: "MarklogicApiClient") -> "FindCaseLawIdentifier":
|
|
@@ -3,6 +3,8 @@ import re
|
|
|
3
3
|
from ds_caselaw_utils import neutral_url
|
|
4
4
|
from ds_caselaw_utils.types import NeutralCitationString
|
|
5
5
|
|
|
6
|
+
from caselawclient.types import DocumentIdentifierSlug
|
|
7
|
+
|
|
6
8
|
from . import Identifier, IdentifierSchema
|
|
7
9
|
|
|
8
10
|
VALID_NCN_PATTERN = re.compile(r"(^\[([0-9]{4})\] ([a-zA-Z]+)(?: ([a-zA-Z]+))? ([0-9]+)(?: \(([a-zA-Z]+)\))?$)")
|
|
@@ -38,13 +40,13 @@ class NeutralCitationNumberSchema(IdentifierSchema):
|
|
|
38
40
|
return bool(VALID_NCN_PATTERN.match(value))
|
|
39
41
|
|
|
40
42
|
@classmethod
|
|
41
|
-
def compile_identifier_url_slug(cls, value: str) ->
|
|
43
|
+
def compile_identifier_url_slug(cls, value: str) -> DocumentIdentifierSlug:
|
|
42
44
|
ncn_based_uri_string = neutral_url(
|
|
43
45
|
NeutralCitationString(value)
|
|
44
46
|
) # TODO: At some point this should move out of utils and into this class.
|
|
45
47
|
if not ncn_based_uri_string:
|
|
46
48
|
raise Exception(f"Unable to convert NCN {value} into NCN-based URL slug")
|
|
47
|
-
return ncn_based_uri_string
|
|
49
|
+
return DocumentIdentifierSlug(ncn_based_uri_string)
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
class NeutralCitationNumber(Identifier):
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from caselawclient.types import DocumentIdentifierSlug
|
|
2
|
+
|
|
1
3
|
from .neutral_citation import NeutralCitationNumber, NeutralCitationNumberSchema
|
|
2
4
|
|
|
3
5
|
|
|
@@ -12,8 +14,8 @@ class PressSummaryRelatedNCNIdentifierSchema(NeutralCitationNumberSchema):
|
|
|
12
14
|
base_score_multiplier = 0.5
|
|
13
15
|
|
|
14
16
|
@classmethod
|
|
15
|
-
def compile_identifier_url_slug(cls, value: str) ->
|
|
16
|
-
return super().compile_identifier_url_slug(value) + "/press-summary"
|
|
17
|
+
def compile_identifier_url_slug(cls, value: str) -> DocumentIdentifierSlug:
|
|
18
|
+
return DocumentIdentifierSlug(super().compile_identifier_url_slug(value) + "/press-summary")
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
class PressSummaryRelatedNCNIdentifier(NeutralCitationNumber):
|
|
@@ -2,8 +2,29 @@ class InvalidDocumentURIException(Exception):
|
|
|
2
2
|
"""The document URI is not valid."""
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
class InvalidMarkLogicDocumentURIException(Exception):
|
|
6
|
+
"""The MarkLogic document URI is not valid."""
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
class MarkLogicDocumentURIString(str):
|
|
6
|
-
|
|
10
|
+
def __new__(cls, content: str) -> "MarkLogicDocumentURIString":
|
|
11
|
+
# Check that the URI begins with a slash
|
|
12
|
+
if content[0] != "/":
|
|
13
|
+
raise InvalidMarkLogicDocumentURIException(
|
|
14
|
+
f'"{content}" is not a valid MarkLogic document URI; URIs must begin with a slash.'
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
# Check that the URI ends with ".xml"
|
|
18
|
+
if not content.endswith(".xml"):
|
|
19
|
+
raise InvalidMarkLogicDocumentURIException(
|
|
20
|
+
f'"{content}" is not a valid MarkLogic document URI; URIs must end with ".xml". '
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# If everything is good, return as usual
|
|
24
|
+
return str.__new__(cls, content)
|
|
25
|
+
|
|
26
|
+
def as_document_uri(self) -> "DocumentURIString":
|
|
27
|
+
return DocumentURIString(self.lstrip("/").rstrip(".xml"))
|
|
7
28
|
|
|
8
29
|
|
|
9
30
|
class DocumentURIString(str):
|
|
@@ -29,3 +50,11 @@ class DocumentURIString(str):
|
|
|
29
50
|
|
|
30
51
|
def as_marklogic(self) -> MarkLogicDocumentURIString:
|
|
31
52
|
return MarkLogicDocumentURIString(f"/{self}.xml")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class DocumentIdentifierSlug(str):
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class DocumentIdentifierValue(str):
|
|
60
|
+
pass
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
xquery version "1.0-ml";
|
|
2
2
|
|
|
3
3
|
declare namespace xdmp="http://marklogic.com/xdmp";
|
|
4
|
-
declare variable $
|
|
4
|
+
declare variable $identifier_slug as xs:string external;
|
|
5
5
|
declare variable $published_only as xs:int? external := 1;
|
|
6
6
|
|
|
7
7
|
let $published_query := if ($published_only) then " AND document_published = 'true'" else ""
|
|
@@ -11,7 +11,6 @@ return xdmp:sql(
|
|
|
11
11
|
$query,
|
|
12
12
|
"map",
|
|
13
13
|
map:new((
|
|
14
|
-
map:entry("uri", $
|
|
14
|
+
map:entry("uri", $identifier_slug)
|
|
15
15
|
))
|
|
16
16
|
)
|
|
17
|
-
|
|
@@ -7,7 +7,7 @@ checks. They are used to enforce appropriately typed variables being passed in t
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from typing import Any, NewType, Optional, TypedDict
|
|
10
|
-
from caselawclient.types import DocumentURIString
|
|
10
|
+
from caselawclient.types import DocumentURIString, DocumentIdentifierSlug, DocumentIdentifierValue
|
|
11
11
|
from caselawclient.types import MarkLogicDocumentURIString as MarkLogicDocumentURIString
|
|
12
12
|
|
|
13
13
|
MarkLogicDocumentVersionURIString = NewType("MarkLogicDocumentVersionURIString", MarkLogicDocumentURIString)
|
|
@@ -143,13 +143,13 @@ class ListJudgmentVersionsDict(MarkLogicAPIDict):
|
|
|
143
143
|
|
|
144
144
|
# resolve_from_identifier_slug.xqy
|
|
145
145
|
class ResolveFromIdentifierSlugDict(MarkLogicAPIDict):
|
|
146
|
-
|
|
146
|
+
identifier_slug: DocumentIdentifierSlug
|
|
147
147
|
published_only: Optional[int]
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
# resolve_from_identifier_value.xqy
|
|
151
151
|
class ResolveFromIdentifierValueDict(MarkLogicAPIDict):
|
|
152
|
-
identifier_value:
|
|
152
|
+
identifier_value: DocumentIdentifierValue
|
|
153
153
|
published_only: Optional[int]
|
|
154
154
|
|
|
155
155
|
|
{ds_caselaw_marklogic_api_client-31.0.1 → ds_caselaw_marklogic_api_client-31.2.0}/LICENSE.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|