ds-caselaw-marklogic-api-client 41.1.3__py3-none-any.whl → 42.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.

Potentially problematic release.


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

File without changes
@@ -0,0 +1,51 @@
1
+ import caselawclient.managers.merge.checks as checks
2
+ from caselawclient.models.documents import Document
3
+ from caselawclient.types import SuccessFailureMessageTuple
4
+
5
+
6
+ def _combine_list_of_successfailure_results(
7
+ validations: list[SuccessFailureMessageTuple],
8
+ ) -> SuccessFailureMessageTuple:
9
+ """Given a list of SuccessFailureMessageTuples, combine the success/failure states and any messages into a single new object representing the overall success/failure state."""
10
+ success = True
11
+ messages: list[str] = []
12
+
13
+ for validation in validations:
14
+ if validation.success is False:
15
+ success = False
16
+
17
+ messages += validation.messages
18
+
19
+ return SuccessFailureMessageTuple(success, messages)
20
+
21
+
22
+ class MergeManager:
23
+ @classmethod
24
+ def check_document_is_safe_as_merge_source(cls, source_document: Document) -> SuccessFailureMessageTuple:
25
+ """
26
+ Is the given document safe to be considered as a merge source?
27
+ """
28
+
29
+ return _combine_list_of_successfailure_results(
30
+ [
31
+ checks.check_document_is_not_version(source_document),
32
+ checks.check_document_has_only_one_version(source_document),
33
+ checks.check_document_has_never_been_published(source_document),
34
+ checks.check_document_is_safe_to_delete(source_document),
35
+ ]
36
+ )
37
+
38
+ @classmethod
39
+ def check_source_document_is_safe_to_merge_into_target(
40
+ cls, source_document: Document, target_document: Document
41
+ ) -> SuccessFailureMessageTuple:
42
+ """Is the given source document safe to merge into a given target?"""
43
+
44
+ return _combine_list_of_successfailure_results(
45
+ [
46
+ checks.check_documents_are_not_same_document(source_document, target_document),
47
+ checks.check_document_is_not_version(target_document),
48
+ checks.check_documents_are_same_type(source_document, target_document),
49
+ checks.check_source_document_is_newer_than_target(source_document, target_document),
50
+ ]
51
+ )
@@ -0,0 +1,79 @@
1
+ from caselawclient.models.documents import Document
2
+ from caselawclient.types import SuccessFailureMessageTuple
3
+
4
+
5
+ def check_document_is_not_version(document: Document) -> SuccessFailureMessageTuple:
6
+ """Check that the document URI isn't a specific version"""
7
+ if document.is_version:
8
+ return SuccessFailureMessageTuple(
9
+ False,
10
+ ["This document is a specific version, and cannot be used as a merge source"],
11
+ )
12
+
13
+ return SuccessFailureMessageTuple(True, [])
14
+
15
+
16
+ def check_document_has_only_one_version(document: Document) -> SuccessFailureMessageTuple:
17
+ """Make sure the document has exactly one version."""
18
+ if len(document.versions) > 1:
19
+ return SuccessFailureMessageTuple(
20
+ False,
21
+ ["This document has more than one version"],
22
+ )
23
+
24
+ return SuccessFailureMessageTuple(True, [])
25
+
26
+
27
+ def check_document_has_never_been_published(document: Document) -> SuccessFailureMessageTuple:
28
+ """Make sure the document has never been published."""
29
+ if document.has_ever_been_published:
30
+ return SuccessFailureMessageTuple(
31
+ False,
32
+ ["This document has previously been published"],
33
+ )
34
+
35
+ return SuccessFailureMessageTuple(True, [])
36
+
37
+
38
+ def check_document_is_safe_to_delete(document: Document) -> SuccessFailureMessageTuple:
39
+ """Make sure the document is safe to delete."""
40
+ if not document.safe_to_delete:
41
+ return SuccessFailureMessageTuple(
42
+ False,
43
+ ["This document cannot be deleted because it is published"],
44
+ )
45
+
46
+ return SuccessFailureMessageTuple(True, [])
47
+
48
+
49
+ def check_documents_are_not_same_document(document_one: Document, document_two: Document) -> SuccessFailureMessageTuple:
50
+ """Check that two documents aren't actually the same"""
51
+ if document_one.uri == document_two.uri:
52
+ return SuccessFailureMessageTuple(
53
+ False,
54
+ ["You cannot merge a document with itself"],
55
+ )
56
+ return SuccessFailureMessageTuple(True, [])
57
+
58
+
59
+ def check_documents_are_same_type(document_one: Document, document_two: Document) -> SuccessFailureMessageTuple:
60
+ """Check to see if this document is the same type as a target document."""
61
+ if type(document_one) is not type(document_two):
62
+ return SuccessFailureMessageTuple(
63
+ False,
64
+ [
65
+ f"The type of {document_one.uri} ({type(document_one).document_noun}) does not match the type of {document_two.uri} ({type(document_two).document_noun})"
66
+ ],
67
+ )
68
+ return SuccessFailureMessageTuple(True, [])
69
+
70
+
71
+ def check_source_document_is_newer_than_target(
72
+ source_document: Document, target_document: Document
73
+ ) -> SuccessFailureMessageTuple:
74
+ """Check to see if the created datetime of the latest version of this document is newer than the created datetime of the latest version of a target document."""
75
+ if source_document.version_created_datetime < target_document.version_created_datetime:
76
+ return SuccessFailureMessageTuple(
77
+ False, [f"The document at {source_document.uri} is older than the latest version of {target_document.uri}"]
78
+ )
79
+ return SuccessFailureMessageTuple(True, [])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ds-caselaw-marklogic-api-client
3
- Version: 41.1.3
3
+ Version: 42.0.0
4
4
  Summary: An API client for interacting with the underlying data in Find Caselaw.
5
5
  Keywords: national archives,caselaw
6
6
  Author: The National Archives
@@ -9,7 +9,7 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Programming Language :: Python :: 3.12
10
10
  Classifier: Programming Language :: Python :: 3.13
11
11
  Requires-Dist: boto3 (>=1.26.112,<2.0.0)
12
- Requires-Dist: certifi (>=2025.8.3,<2025.9.0)
12
+ Requires-Dist: certifi (>=2025.10.5,<2025.11.0)
13
13
  Requires-Dist: charset-normalizer (>=3.0.0,<4.0.0)
14
14
  Requires-Dist: defusedxml (>=0.7.1,<0.8.0)
15
15
  Requires-Dist: django-environ (>=0.12.0)
@@ -6,6 +6,9 @@ caselawclient/content_hash.py,sha256=0cPC4OoABq0SC2wYFX9-24DodNigeOqksDxgxQH_hUA
6
6
  caselawclient/errors.py,sha256=JC16fEGq_MRJX-_KFzfINCV2Cqx8o6OWOt3C16rQd84,3142
7
7
  caselawclient/factories.py,sha256=HXJeWpN7__X462joco07ziNqMOOMr-wUPJ91Y69gFk8,7466
8
8
  caselawclient/identifier_resolution.py,sha256=B5I1sD7o7YjzsXMECjbKjgiGLDda5bGhejsJ-lYpTIg,2429
9
+ caselawclient/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ caselawclient/managers/merge/__init__.py,sha256=Rd6YIGifT3TP6UOf0gBrRoYzK5MJqTPeRaIJznS8dgI,2078
11
+ caselawclient/managers/merge/checks.py,sha256=J9RBG6jZAKIZk27jdFq-BByoRLKWsViCfHDyA8ZM3qU,3205
9
12
  caselawclient/models/__init__.py,sha256=kd23EUpvaC7aLHdgk8farqKAQEx3lf7RvNT2jEatvlg,68
10
13
  caselawclient/models/documents/__init__.py,sha256=kBgu7V049KP5cBxH0GyePuD1gWoVs5JZFRdTzuMVKrE,24375
11
14
  caselawclient/models/documents/body.py,sha256=pzk3bm9FGIWfI0Hs8dBuzk6RCiA9M4GHfgOYKpNlzyE,8455
@@ -89,7 +92,7 @@ caselawclient/xquery/xslt_transform.xqy,sha256=cccaFiGkCcvSfDv007UriZ3I4ak2nTLP1
89
92
  caselawclient/xquery_type_dicts.py,sha256=f4PM8yZi5RRMdL2lQ8tsLUs0aJjBa5chvd-VVj40fJY,6767
90
93
  caselawclient/xslt/modify_xml_live.xsl,sha256=gNjwBun2-UzOeeuf0wNjFtN3jXm1yrwqv_KT8r1slXw,2370
91
94
  caselawclient/xslt/sample.xsl,sha256=IG-v77stjwqiw25pguh391K-5DTKiX651WqILDZixm0,825
92
- ds_caselaw_marklogic_api_client-41.1.3.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
93
- ds_caselaw_marklogic_api_client-41.1.3.dist-info/METADATA,sha256=02VyE_L3WKKb8uYBE9No9KhDVLx6rXninOg-76KspiY,4364
94
- ds_caselaw_marklogic_api_client-41.1.3.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
95
- ds_caselaw_marklogic_api_client-41.1.3.dist-info/RECORD,,
95
+ ds_caselaw_marklogic_api_client-42.0.0.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
96
+ ds_caselaw_marklogic_api_client-42.0.0.dist-info/METADATA,sha256=UWzlCKwEKEc97aTLyHk3zvmmIaB6PFQVc8rC1a-oUOA,4366
97
+ ds_caselaw_marklogic_api_client-42.0.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
98
+ ds_caselaw_marklogic_api_client-42.0.0.dist-info/RECORD,,