ds-caselaw-marklogic-api-client 35.1.0__py3-none-any.whl → 36.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.
- caselawclient/factories.py +2 -2
- caselawclient/identifier_resolution.py +1 -1
- caselawclient/models/identifiers/__init__.py +7 -8
- caselawclient/models/identifiers/exceptions.py +10 -0
- caselawclient/models/identifiers/neutral_citation.py +24 -2
- caselawclient/models/identifiers/unpacker.py +2 -1
- caselawclient/models/utilities/aws.py +1 -0
- {ds_caselaw_marklogic_api_client-35.1.0.dist-info → ds_caselaw_marklogic_api_client-36.0.0.dist-info}/METADATA +2 -2
- {ds_caselaw_marklogic_api_client-35.1.0.dist-info → ds_caselaw_marklogic_api_client-36.0.0.dist-info}/RECORD +11 -10
- {ds_caselaw_marklogic_api_client-35.1.0.dist-info → ds_caselaw_marklogic_api_client-36.0.0.dist-info}/LICENSE.md +0 -0
- {ds_caselaw_marklogic_api_client-35.1.0.dist-info → ds_caselaw_marklogic_api_client-36.0.0.dist-info}/WHEEL +0 -0
caselawclient/factories.py
CHANGED
|
@@ -85,7 +85,7 @@ class DocumentFactory:
|
|
|
85
85
|
document.body = kwargs.pop("body") if "body" in kwargs else DocumentBodyFactory.build()
|
|
86
86
|
|
|
87
87
|
if identifiers is None:
|
|
88
|
-
document.identifiers.add(FindCaseLawIdentifier(value="
|
|
88
|
+
document.identifiers.add(FindCaseLawIdentifier(value="tn4t35ts"))
|
|
89
89
|
else:
|
|
90
90
|
for identifier in identifiers:
|
|
91
91
|
document.identifiers.add(identifier)
|
|
@@ -173,7 +173,7 @@ class IdentifierResolutionFactory:
|
|
|
173
173
|
"documents.compiled_url_slugs.identifier_uuid": resolution_uuid or "24b9a384-8bcf-4f20-996a-5c318f8dc657",
|
|
174
174
|
"documents.compiled_url_slugs.document_uri": document_uri or "/ewca/civ/2003/547.xml",
|
|
175
175
|
"documents.compiled_url_slugs.identifier_slug": identifier_slug or "ewca/civ/2003/54721",
|
|
176
|
-
"documents.compiled_url_slugs.document_published":
|
|
176
|
+
"documents.compiled_url_slugs.document_published": published,
|
|
177
177
|
"documents.compiled_url_slugs.identifier_namespace": namespace or "ukncn",
|
|
178
178
|
"documents.compiled_url_slugs.identifier_value": value or "[2003] EWCA 54721 (Civ)",
|
|
179
179
|
}
|
|
@@ -45,7 +45,7 @@ class IdentifierResolution(NamedTuple):
|
|
|
45
45
|
identifier_uuid=row["documents.compiled_url_slugs.identifier_uuid"],
|
|
46
46
|
document_uri=MarkLogicDocumentURIString(row["documents.compiled_url_slugs.document_uri"]),
|
|
47
47
|
identifier_slug=DocumentIdentifierSlug(row["documents.compiled_url_slugs.identifier_slug"]),
|
|
48
|
-
document_published=row["documents.compiled_url_slugs.document_published"]
|
|
48
|
+
document_published=row["documents.compiled_url_slugs.document_published"],
|
|
49
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],
|
|
@@ -6,6 +6,8 @@ from lxml import etree
|
|
|
6
6
|
|
|
7
7
|
from caselawclient.types import DocumentIdentifierSlug, DocumentIdentifierValue
|
|
8
8
|
|
|
9
|
+
from .exceptions import IdentifierValidationException, UUIDMismatchError
|
|
10
|
+
|
|
9
11
|
IDENTIFIER_PACKABLE_ATTRIBUTES: list[str] = [
|
|
10
12
|
"uuid",
|
|
11
13
|
"value",
|
|
@@ -18,14 +20,6 @@ IDENTIFIER_UNPACKABLE_ATTRIBUTES: list[str] = [
|
|
|
18
20
|
]
|
|
19
21
|
|
|
20
22
|
|
|
21
|
-
class InvalidIdentifierXMLRepresentationException(Exception):
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class UUIDMismatchError(Exception):
|
|
26
|
-
pass
|
|
27
|
-
|
|
28
|
-
|
|
29
23
|
class IdentifierSchema(ABC):
|
|
30
24
|
"""
|
|
31
25
|
A base class which describes what an identifier schema should look like.
|
|
@@ -89,6 +83,11 @@ class Identifier(ABC):
|
|
|
89
83
|
return self.value
|
|
90
84
|
|
|
91
85
|
def __init__(self, value: str, uuid: Optional[str] = None) -> None:
|
|
86
|
+
if not self.schema.validate_identifier(value=value):
|
|
87
|
+
raise IdentifierValidationException(
|
|
88
|
+
f'Identifier value "{value}" is not valid according to the {self.schema.name} schema.'
|
|
89
|
+
)
|
|
90
|
+
|
|
92
91
|
self.value = DocumentIdentifierValue(value)
|
|
93
92
|
if uuid:
|
|
94
93
|
self.uuid = uuid
|
|
@@ -6,6 +6,7 @@ from ds_caselaw_utils.types import NeutralCitationString
|
|
|
6
6
|
from caselawclient.types import DocumentIdentifierSlug
|
|
7
7
|
|
|
8
8
|
from . import Identifier, IdentifierSchema
|
|
9
|
+
from .exceptions import IdentifierValidationException
|
|
9
10
|
|
|
10
11
|
VALID_NCN_PATTERN = re.compile(r"(^\[([0-9]{4})\] ([a-zA-Z]+)(?: ([a-zA-Z]+))? ([0-9]+)(?: \(([a-zA-Z]+)\))?$)")
|
|
11
12
|
"""
|
|
@@ -23,6 +24,18 @@ TODO: When these capture groups are being used in anger (eg to build URL slugs)
|
|
|
23
24
|
"""
|
|
24
25
|
|
|
25
26
|
|
|
27
|
+
class NCNValidationException(IdentifierValidationException):
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class NCNDoesNotMatchExpectedPatternException(NCNValidationException):
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class NCNCannotConvertToValidURLSlugException(NCNValidationException):
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
|
|
26
39
|
class NeutralCitationNumberSchema(IdentifierSchema):
|
|
27
40
|
"""
|
|
28
41
|
Identifier schema describing a Neutral Citation Number.
|
|
@@ -37,7 +50,16 @@ class NeutralCitationNumberSchema(IdentifierSchema):
|
|
|
37
50
|
|
|
38
51
|
@classmethod
|
|
39
52
|
def validate_identifier(cls, value: str) -> bool:
|
|
40
|
-
|
|
53
|
+
# Quick check to see if the NCN matches the expected pattern
|
|
54
|
+
if not bool(VALID_NCN_PATTERN.match(value)):
|
|
55
|
+
raise NCNDoesNotMatchExpectedPatternException(f"NCN '{value}' is not in the expected format")
|
|
56
|
+
|
|
57
|
+
# Can we convert this to a URL? neutral_url returns False if not.
|
|
58
|
+
# This functionally tests to see if the court exists, since only valid patterns (where we know how to match the court code) will convert
|
|
59
|
+
if not neutral_url(NeutralCitationString(value)):
|
|
60
|
+
raise NCNCannotConvertToValidURLSlugException(f"NCN '{value}' cannot be converted to an NCN-based URL slug")
|
|
61
|
+
|
|
62
|
+
return True
|
|
41
63
|
|
|
42
64
|
@classmethod
|
|
43
65
|
def compile_identifier_url_slug(cls, value: str) -> DocumentIdentifierSlug:
|
|
@@ -45,7 +67,7 @@ class NeutralCitationNumberSchema(IdentifierSchema):
|
|
|
45
67
|
NeutralCitationString(value)
|
|
46
68
|
) # TODO: At some point this should move out of utils and into this class.
|
|
47
69
|
if not ncn_based_uri_string:
|
|
48
|
-
raise
|
|
70
|
+
raise NCNCannotConvertToValidURLSlugException(f"NCN '{value}' cannot be converted to an NCN-based URL slug")
|
|
49
71
|
return DocumentIdentifierSlug(ncn_based_uri_string)
|
|
50
72
|
|
|
51
73
|
|
|
@@ -3,7 +3,8 @@ from warnings import warn
|
|
|
3
3
|
|
|
4
4
|
from lxml import etree
|
|
5
5
|
|
|
6
|
-
from . import IDENTIFIER_UNPACKABLE_ATTRIBUTES, Identifier, Identifiers
|
|
6
|
+
from . import IDENTIFIER_UNPACKABLE_ATTRIBUTES, Identifier, Identifiers
|
|
7
|
+
from .exceptions import InvalidIdentifierXMLRepresentationException
|
|
7
8
|
from .fclid import FindCaseLawIdentifier
|
|
8
9
|
from .neutral_citation import NeutralCitationNumber
|
|
9
10
|
from .press_summary_ncn import PressSummaryRelatedNCNIdentifier
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ds-caselaw-marklogic-api-client
|
|
3
|
-
Version:
|
|
3
|
+
Version: 36.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
|
|
@@ -10,7 +10,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
12
|
Requires-Dist: boto3 (>=1.26.112,<2.0.0)
|
|
13
|
-
Requires-Dist: certifi (>=2025.
|
|
13
|
+
Requires-Dist: certifi (>=2025.4.26,<2025.5.0)
|
|
14
14
|
Requires-Dist: charset-normalizer (>=3.0.0,<4.0.0)
|
|
15
15
|
Requires-Dist: django-environ (>=0.12.0)
|
|
16
16
|
Requires-Dist: ds-caselaw-utils (>=2.0.0,<3.0.0)
|
|
@@ -4,8 +4,8 @@ caselawclient/client_helpers/__init__.py,sha256=eucyUXwUqI72TPw-C5zLcHlMu4GtFY50
|
|
|
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
|
|
7
|
-
caselawclient/factories.py,sha256=
|
|
8
|
-
caselawclient/identifier_resolution.py,sha256=
|
|
7
|
+
caselawclient/factories.py,sha256=tbF3iV3WpHm-z_2aRCV4Dg6ZLBkQuc_egdcd_oWCIlI,6791
|
|
8
|
+
caselawclient/identifier_resolution.py,sha256=B5I1sD7o7YjzsXMECjbKjgiGLDda5bGhejsJ-lYpTIg,2429
|
|
9
9
|
caselawclient/models/__init__.py,sha256=kd23EUpvaC7aLHdgk8farqKAQEx3lf7RvNT2jEatvlg,68
|
|
10
10
|
caselawclient/models/documents/__init__.py,sha256=7U5oN2b8JZV9sFSYglBg2K7fKKQgDjTVU5FT22URx7U,19043
|
|
11
11
|
caselawclient/models/documents/body.py,sha256=mhPOV1cOF3RJr69UzNPlo1KrzePaj7KDPYi1exP06L0,5880
|
|
@@ -13,17 +13,18 @@ caselawclient/models/documents/exceptions.py,sha256=Mz1P8uNqf5w6uLnRwJt6xK7efsVq
|
|
|
13
13
|
caselawclient/models/documents/statuses.py,sha256=Cp4dTQmJOtsU41EJcxy5dV1841pGD2PNWH0VrkDEv4Q,579
|
|
14
14
|
caselawclient/models/documents/transforms/html.xsl,sha256=oSSO-IBX4qLiSWexQYmWJfGNevF09aCBx4D1NYqXxpo,38322
|
|
15
15
|
caselawclient/models/documents/xml.py,sha256=HlmPb63lLMnySSOLP4iexcAyQiLByKBZtTd25f8sY8M,1268
|
|
16
|
-
caselawclient/models/identifiers/__init__.py,sha256=
|
|
16
|
+
caselawclient/models/identifiers/__init__.py,sha256=_iAsx_e-Rxq3ED3TQQ5Vg1ZNnQn6AZQK8QCvHSFhdGg,6848
|
|
17
|
+
caselawclient/models/identifiers/exceptions.py,sha256=ckVsjPzLuTXkbd7KZRJXoxcltQCXPGL2rMyYwE5orgg,177
|
|
17
18
|
caselawclient/models/identifiers/fclid.py,sha256=Gq0G0eLdUH3j7VybluqJGVcHV3Y-hpjty1OdR91dI5Q,1453
|
|
18
|
-
caselawclient/models/identifiers/neutral_citation.py,sha256=
|
|
19
|
+
caselawclient/models/identifiers/neutral_citation.py,sha256=cgB1PO44ra8dKsYGq9_g53be8T1mQatq9Hh_DN5DVg0,2868
|
|
19
20
|
caselawclient/models/identifiers/press_summary_ncn.py,sha256=CKhNTnO6pfriS4Sg-gt0Pf0fRhH53Uf0flULPncJWM4,762
|
|
20
|
-
caselawclient/models/identifiers/unpacker.py,sha256=
|
|
21
|
+
caselawclient/models/identifiers/unpacker.py,sha256=fKfiuTKaN-71e40PV8BC9PueKjwgfX9Xw3IVdy8mkqg,2299
|
|
21
22
|
caselawclient/models/judgments.py,sha256=r40irgdEID-NeSNLm3OUdUBznMpRSwjD2SJrGlBgP8o,2208
|
|
22
23
|
caselawclient/models/neutral_citation_mixin.py,sha256=jAac3PPuWyPdj9N-n-U_JfwkbgbSIXaqFVQahfu95do,2086
|
|
23
24
|
caselawclient/models/parser_logs.py,sha256=30kF4w0GcowiMIFtymUkl7ZARanNh_PjDpJZezn-cA8,315
|
|
24
25
|
caselawclient/models/press_summaries.py,sha256=PIq9RceZ7n7Z079tESfxhQbfxCmtTc2V2OeFtcn594s,2144
|
|
25
26
|
caselawclient/models/utilities/__init__.py,sha256=u3yIhbTjFQ1JJyAm5wsMEBswWl4t6Z7UMORF5FqC2xQ,1257
|
|
26
|
-
caselawclient/models/utilities/aws.py,sha256=
|
|
27
|
+
caselawclient/models/utilities/aws.py,sha256=NTF2W2aNgbO72e5WklXZC2U2_GPbVeynjTS1Nqu6DcE,8561
|
|
27
28
|
caselawclient/models/utilities/dates.py,sha256=WwORxVjUHM1ZFcBF6Qtwo3Cj0sATsnSECkUZ6ls1N1Q,492
|
|
28
29
|
caselawclient/models/utilities/move.py,sha256=MXdUqkSiyqRb8YKs_66B6ICWn8EWM6DiJV95fuJO1Us,3610
|
|
29
30
|
caselawclient/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -81,7 +82,7 @@ caselawclient/xquery/validate_document.xqy,sha256=PgaDcnqCRJPIVqfmWsNlXmCLNKd21q
|
|
|
81
82
|
caselawclient/xquery/xslt.xqy,sha256=w57wNijH3dkwHkpKeAxqjlghVflQwo8cq6jS_sm-erM,199
|
|
82
83
|
caselawclient/xquery/xslt_transform.xqy,sha256=cccaFiGkCcvSfDv007UriZ3I4ak2nTLP1trRZdbOoS8,2462
|
|
83
84
|
caselawclient/xquery_type_dicts.py,sha256=21V6PJ0a8lPZuwzQCWeHNo914hdCbCJtOvnqdHcTpKk,6383
|
|
84
|
-
ds_caselaw_marklogic_api_client-
|
|
85
|
-
ds_caselaw_marklogic_api_client-
|
|
86
|
-
ds_caselaw_marklogic_api_client-
|
|
87
|
-
ds_caselaw_marklogic_api_client-
|
|
85
|
+
ds_caselaw_marklogic_api_client-36.0.0.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
|
|
86
|
+
ds_caselaw_marklogic_api_client-36.0.0.dist-info/METADATA,sha256=ZIEcK86tOf0ruMjnRFKcq4N65_x8HKUBiF7PNFHj-YM,4206
|
|
87
|
+
ds_caselaw_marklogic_api_client-36.0.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
|
88
|
+
ds_caselaw_marklogic_api_client-36.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|