documente_shared 0.1.71__py3-none-any.whl → 0.1.72b0__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 documente_shared might be problematic. Click here for more details.

Files changed (41) hide show
  1. documente_shared/__init__.py +0 -0
  2. documente_shared/application/__init__.py +0 -0
  3. documente_shared/application/digest.py +7 -7
  4. documente_shared/application/exceptions.py +23 -23
  5. documente_shared/application/files.py +22 -22
  6. documente_shared/application/time_utils.py +13 -13
  7. documente_shared/application/timezone.py +7 -7
  8. documente_shared/domain/__init__.py +0 -0
  9. documente_shared/domain/base_enum.py +53 -53
  10. documente_shared/domain/constants.py +2 -2
  11. documente_shared/domain/entities/__init__.py +0 -0
  12. documente_shared/domain/entities/document.py +348 -348
  13. documente_shared/domain/entities/document_metadata.py +63 -63
  14. documente_shared/domain/entities/in_memory_result.py +51 -51
  15. documente_shared/domain/entities/processing_case.py +144 -139
  16. documente_shared/domain/entities/processing_case_item.py +216 -210
  17. documente_shared/domain/entities/processing_event.py +49 -49
  18. documente_shared/domain/enums/__init__.py +0 -0
  19. documente_shared/domain/enums/common.py +95 -95
  20. documente_shared/domain/enums/document.py +71 -71
  21. documente_shared/domain/enums/processing_case.py +54 -54
  22. documente_shared/domain/repositories/__init__.py +0 -0
  23. documente_shared/domain/repositories/document.py +24 -24
  24. documente_shared/domain/repositories/processing_case.py +24 -24
  25. documente_shared/domain/repositories/processing_case_item.py +29 -29
  26. documente_shared/infrastructure/__init__.py +0 -0
  27. documente_shared/infrastructure/documente_client.py +21 -0
  28. documente_shared/infrastructure/dynamo_table.py +75 -75
  29. documente_shared/infrastructure/repositories/__init__.py +0 -0
  30. documente_shared/infrastructure/repositories/dynamo_document.py +43 -43
  31. documente_shared/infrastructure/repositories/dynamo_processing_case.py +43 -43
  32. documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +53 -53
  33. documente_shared/infrastructure/repositories/http_document_processing.py +41 -0
  34. documente_shared/infrastructure/repositories/http_processing_case.py +41 -0
  35. documente_shared/infrastructure/repositories/http_processing_case_item.py +53 -0
  36. documente_shared/infrastructure/s3_bucket.py +57 -57
  37. documente_shared/infrastructure/sqs_queue.py +47 -47
  38. {documente_shared-0.1.71.dist-info → documente_shared-0.1.72b0.dist-info}/METADATA +2 -1
  39. documente_shared-0.1.72b0.dist-info/RECORD +40 -0
  40. documente_shared-0.1.71.dist-info/RECORD +0 -36
  41. {documente_shared-0.1.71.dist-info → documente_shared-0.1.72b0.dist-info}/WHEEL +0 -0
@@ -1,57 +1,57 @@
1
- import boto3
2
-
3
- from dataclasses import dataclass
4
- from typing import Optional
5
-
6
- from documente_shared.domain.entities.document import remove_slash_from_path
7
-
8
-
9
- def remove_none_values(data: dict) -> dict: # noqa: WPS110
10
- return {key: value for key, value in data.items() if value is not None} # noqa: WPS110
11
-
12
-
13
- @dataclass
14
- class S3Bucket(object):
15
- bucket_name: str
16
-
17
- def __post_init__(self):
18
- self._resource = boto3.resource('s3')
19
-
20
- def get(self, file_key: str) -> Optional[dict]:
21
- try:
22
- return self._resource.Object(self.bucket_name, file_key).get()
23
- except self._resource.meta.client.exceptions.NoSuchKey:
24
- return None
25
-
26
- def get_bytes(self, file_key: str) -> Optional[bytes]:
27
- cleaned_file_key = remove_slash_from_path(file_key)
28
- file_context = self.get(cleaned_file_key)
29
- if not file_context:
30
- return None
31
- return (
32
- file_context['Body'].read()
33
- if 'Body' in file_context
34
- else None
35
- )
36
-
37
- def upload(self, file_key: str, file_content, content_type: Optional[str] = None):
38
- cleaned_file_key = remove_slash_from_path(file_key)
39
- optional_params = {'ContentType': content_type}
40
- return self._resource.Object(self.bucket_name, cleaned_file_key).put(
41
- Body=file_content,
42
- **remove_none_values(optional_params),
43
- )
44
-
45
- def delete(self, file_key: str):
46
- cleaned_file_key = remove_slash_from_path(file_key)
47
- return self._resource.Object(self.bucket_name, cleaned_file_key).delete()
48
-
49
- def get_url(self, file_key: str):
50
- cleaned_file_key = remove_slash_from_path(file_key)
51
- return 'https://{bucket_url}.s3.amazonaws.com/{file_key}'.format(
52
- bucket_url=self.bucket_name,
53
- file_key=cleaned_file_key,
54
- )
55
-
56
- def read(self, file_key: str) -> bytes:
57
- return self.get(file_key)['Body'].read()
1
+ import boto3
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Optional
5
+
6
+ from documente_shared.domain.entities.document import remove_slash_from_path
7
+
8
+
9
+ def remove_none_values(data: dict) -> dict: # noqa: WPS110
10
+ return {key: value for key, value in data.items() if value is not None} # noqa: WPS110
11
+
12
+
13
+ @dataclass
14
+ class S3Bucket(object):
15
+ bucket_name: str
16
+
17
+ def __post_init__(self):
18
+ self._resource = boto3.resource('s3')
19
+
20
+ def get(self, file_key: str) -> Optional[dict]:
21
+ try:
22
+ return self._resource.Object(self.bucket_name, file_key).get()
23
+ except self._resource.meta.client.exceptions.NoSuchKey:
24
+ return None
25
+
26
+ def get_bytes(self, file_key: str) -> Optional[bytes]:
27
+ cleaned_file_key = remove_slash_from_path(file_key)
28
+ file_context = self.get(cleaned_file_key)
29
+ if not file_context:
30
+ return None
31
+ return (
32
+ file_context['Body'].read()
33
+ if 'Body' in file_context
34
+ else None
35
+ )
36
+
37
+ def upload(self, file_key: str, file_content, content_type: Optional[str] = None):
38
+ cleaned_file_key = remove_slash_from_path(file_key)
39
+ optional_params = {'ContentType': content_type}
40
+ return self._resource.Object(self.bucket_name, cleaned_file_key).put(
41
+ Body=file_content,
42
+ **remove_none_values(optional_params),
43
+ )
44
+
45
+ def delete(self, file_key: str):
46
+ cleaned_file_key = remove_slash_from_path(file_key)
47
+ return self._resource.Object(self.bucket_name, cleaned_file_key).delete()
48
+
49
+ def get_url(self, file_key: str):
50
+ cleaned_file_key = remove_slash_from_path(file_key)
51
+ return 'https://{bucket_url}.s3.amazonaws.com/{file_key}'.format(
52
+ bucket_url=self.bucket_name,
53
+ file_key=cleaned_file_key,
54
+ )
55
+
56
+ def read(self, file_key: str) -> bytes:
57
+ return self.get(file_key)['Body'].read()
@@ -1,48 +1,48 @@
1
- import json
2
- import boto3
3
-
4
- from dataclasses import dataclass
5
-
6
-
7
- @dataclass
8
- class SQSQueue(object):
9
- queue_url: str
10
- visibility_timeout: int = 60 * 10
11
- waiting_timeout: int = 20
12
-
13
- def __post_init__(self):
14
- self._client = boto3.client('sqs')
15
-
16
- def send_message(
17
- self,
18
- payload: dict,
19
- message_attributes: dict = None,
20
- delay_seconds: dict = None,
21
- message_group_id: dict = None,
22
- message_deduplication_id: dict =None,
23
- ):
24
- message_params = {
25
- 'QueueUrl': self.queue_url,
26
- 'MessageBody': json.dumps(payload),
27
- 'MessageAttributes': message_attributes,
28
- 'DelaySeconds': delay_seconds,
29
- 'MessageGroupId': message_group_id,
30
- 'MessageDeduplicationId': message_deduplication_id,
31
- }
32
- clean_params = {key: value for key, value in message_params.items() if value}
33
- return self._client.send_message(**clean_params)
34
-
35
- def delete_message(self, receipt_handle: str):
36
- return self._client.delete_message(
37
- QueueUrl=self.queue_url,
38
- ReceiptHandle=receipt_handle
39
- )
40
-
41
- def fetch_messages(self, num_messages: int = 1) -> list[dict]:
42
- response = self._client.receive_message(
43
- QueueUrl=self.queue_url,
44
- MaxNumberOfMessages=num_messages,
45
- VisibilityTimeout=self.visibility_timeout,
46
- WaitTimeSeconds=self.waiting_timeout,
47
- )
1
+ import json
2
+ import boto3
3
+
4
+ from dataclasses import dataclass
5
+
6
+
7
+ @dataclass
8
+ class SQSQueue(object):
9
+ queue_url: str
10
+ visibility_timeout: int = 60 * 10
11
+ waiting_timeout: int = 20
12
+
13
+ def __post_init__(self):
14
+ self._client = boto3.client('sqs')
15
+
16
+ def send_message(
17
+ self,
18
+ payload: dict,
19
+ message_attributes: dict = None,
20
+ delay_seconds: dict = None,
21
+ message_group_id: dict = None,
22
+ message_deduplication_id: dict =None,
23
+ ):
24
+ message_params = {
25
+ 'QueueUrl': self.queue_url,
26
+ 'MessageBody': json.dumps(payload),
27
+ 'MessageAttributes': message_attributes,
28
+ 'DelaySeconds': delay_seconds,
29
+ 'MessageGroupId': message_group_id,
30
+ 'MessageDeduplicationId': message_deduplication_id,
31
+ }
32
+ clean_params = {key: value for key, value in message_params.items() if value}
33
+ return self._client.send_message(**clean_params)
34
+
35
+ def delete_message(self, receipt_handle: str):
36
+ return self._client.delete_message(
37
+ QueueUrl=self.queue_url,
38
+ ReceiptHandle=receipt_handle
39
+ )
40
+
41
+ def fetch_messages(self, num_messages: int = 1) -> list[dict]:
42
+ response = self._client.receive_message(
43
+ QueueUrl=self.queue_url,
44
+ MaxNumberOfMessages=num_messages,
45
+ VisibilityTimeout=self.visibility_timeout,
46
+ WaitTimeSeconds=self.waiting_timeout,
47
+ )
48
48
  return response.get('Messages', [])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.71
3
+ Version: 0.1.72b0
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.12
14
14
  Requires-Dist: boto3 (>=1.37.19,<2.0.0)
15
15
  Requires-Dist: botocore (>=1.37.19,<2.0.0)
16
16
  Requires-Dist: pytz (>=2025.2,<2026.0)
17
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
17
18
  Requires-Dist: sentry-sdk (>=2.19.2,<3.0.0)
18
19
  Description-Content-Type: text/markdown
19
20
 
@@ -0,0 +1,40 @@
1
+ documente_shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ documente_shared/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ documente_shared/application/digest.py,sha256=9T5e5SC1EKYrIjcmzqnlG29pyjJl29q0kdNl-zgsmws,179
4
+ documente_shared/application/exceptions.py,sha256=zrV-wPYXLFUQhA_0hoXKnFAhNntNG17oGB_MU_YhtIg,677
5
+ documente_shared/application/files.py,sha256=EOm6TQWXXjlX-6dQeY2__GdVrzeMDZVnoPU_bVtZDB0,671
6
+ documente_shared/application/time_utils.py,sha256=YBgiJfVdLo2IlgS2Kxp24DY5AwSByDqZ3QjiaOwPKGs,448
7
+ documente_shared/application/timezone.py,sha256=RlLmdvGlMJ-TSfGrTRm1wlJPwpc-_bu9RtWwdKYIPfo,190
8
+ documente_shared/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ documente_shared/domain/base_enum.py,sha256=KihiZGq1ylvQaWjEWtPHCAw9uFpFWsu8eJtLB_nwaWs,1502
10
+ documente_shared/domain/constants.py,sha256=lws6A8b4KM2ch9DAh4Xvpvi_1oWNf_cc0kL3NwpMUOc,58
11
+ documente_shared/domain/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ documente_shared/domain/entities/document.py,sha256=8iLXzJ0qcy1LAgztsTyOzk_DthgJddH5xyTATS5sShw,12943
13
+ documente_shared/domain/entities/document_metadata.py,sha256=QXFy0UemTrECVUFWpsE9o-ZI5Va7QHjvyhNA55a-n9s,2416
14
+ documente_shared/domain/entities/in_memory_result.py,sha256=wG_yWdDglt3BMW0mtc2YFZwBeTrx4_2H92IuqaMK01Q,1297
15
+ documente_shared/domain/entities/processing_case.py,sha256=RlvG2ioQ439PeKcpjczLcwipMYsOVOriT6B1aPzW0OM,5301
16
+ documente_shared/domain/entities/processing_case_item.py,sha256=4TIAJPviUSY77pHWlXZ36R3hkziuHiKpZj9YsXA5NEs,8212
17
+ documente_shared/domain/entities/processing_event.py,sha256=oCi5ym5HcmACKFYoExXEq8pgVAskx7jAttpsvptTGLQ,1772
18
+ documente_shared/domain/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ documente_shared/domain/enums/common.py,sha256=fxLkGAfJStNmJDBN6jyLXDD_d3T65DZqZCgSFVRDQ0s,2357
20
+ documente_shared/domain/enums/document.py,sha256=GlAUn_Rq0wzf98iQQNBxQRO6n-0_1LjRm6zYIi2irj0,1898
21
+ documente_shared/domain/enums/processing_case.py,sha256=3cJ8gLcqWqKtohW1kd1PiGGXx13SkY80mnSTInDutMA,1600
22
+ documente_shared/domain/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ documente_shared/domain/repositories/document.py,sha256=SSqc3zuVpCfnr3OdRj5huREiOYvlID7JSmuFHDtEeg4,791
24
+ documente_shared/domain/repositories/processing_case.py,sha256=xF16EoarAaSmH54w50yBaDwNWrAasZXCEb2q2gxKoOk,753
25
+ documente_shared/domain/repositories/processing_case_item.py,sha256=zOZvjc4Vfc9avgMNr0GEMiCD5fgKB9KJUVhRalbA_Rs,986
26
+ documente_shared/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ documente_shared/infrastructure/documente_client.py,sha256=iuwpNBa9H02a36xqDRt8ffT3KlIMkHkV4mt0RtuvZXo,515
28
+ documente_shared/infrastructure/dynamo_table.py,sha256=Kdz2iViRb5C7wlfbBDp-JDcu2dq_MY1io3gB1uLff0A,2187
29
+ documente_shared/infrastructure/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
+ documente_shared/infrastructure/repositories/dynamo_document.py,sha256=-zf33Dey17_IPsqpUeczZyD2MGzzK9LfV6j-8iQLYPY,1486
31
+ documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=kV1D6T19BW9veUyDIgcijelndiGO5e1tOinBGV8S908,1444
32
+ documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha256=AghVYUMr9sFG3-pz1A2YctBDxKe1P9447tjhomdHbWI,1865
33
+ documente_shared/infrastructure/repositories/http_document_processing.py,sha256=vDFFz3yCLscXt-lyMSNOFMeZdfq6D4lLj_ndG4CSNGM,1752
34
+ documente_shared/infrastructure/repositories/http_processing_case.py,sha256=oRDn-A2HCDJsEfDL4lyh4jrTQ_oTLEazCBQeIUYnYKw,1675
35
+ documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=LZXf_FG9OZT51DbOYPupT1pGdhRsC8IOEo1nnib4yeo,2244
36
+ documente_shared/infrastructure/s3_bucket.py,sha256=qPCBpheM1qvtC08vynlwIGJZCCOhefFcD3Q3ClusXmM,1989
37
+ documente_shared/infrastructure/sqs_queue.py,sha256=UcjrT23JpK1Em9f0qbxI7oYnCPUD7Ll1aJ4JICcqPRo,1551
38
+ documente_shared-0.1.72b0.dist-info/METADATA,sha256=0QOi_tenMNop-s7L3Grz-u3PnFUrxdUQwupWownkeGg,883
39
+ documente_shared-0.1.72b0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
40
+ documente_shared-0.1.72b0.dist-info/RECORD,,
@@ -1,36 +0,0 @@
1
- documente_shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- documente_shared/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- documente_shared/application/digest.py,sha256=Um6E8WfFri2_lly4RFWydJyvSfPZGFcOX-opEOzDCWc,172
4
- documente_shared/application/exceptions.py,sha256=lQM8m7wmI9OTLGva0gd7s7YT7ldaTk_Ln4t32PpzNf8,654
5
- documente_shared/application/files.py,sha256=ADiWi6Mk3YQGx3boGsDqdb5wk8qmabkGRy7bhNFa1OY,649
6
- documente_shared/application/time_utils.py,sha256=_fxgh8VoGPkdsft47COJ16vFwt8pMbHIJCgDFHLSlrU,435
7
- documente_shared/application/timezone.py,sha256=NHpzTzOPD_fWQiJ4BrRqt_TIDs5XyB5ZMR7x8vUk8gQ,183
8
- documente_shared/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- documente_shared/domain/base_enum.py,sha256=DojAfn-zQdtjtImeHUpBzE6TBTm07XrbMOdW3h8RVd8,1449
10
- documente_shared/domain/constants.py,sha256=jOlMKFq12FgiYMJcQHku8IVwuOE5t-HEPuSV_zEeIFo,56
11
- documente_shared/domain/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- documente_shared/domain/entities/document.py,sha256=AthTUyA-QZE3WAT7lMoKVr_Z8mO_3qERuCnZge0DTLQ,12595
13
- documente_shared/domain/entities/document_metadata.py,sha256=ygyFIC5qwxlm8DUM5kvVFny9zJfPQS8vNLM2br5XsQ8,2353
14
- documente_shared/domain/entities/in_memory_result.py,sha256=Q1E9vnLL5Hz5xunOqWtQmJOMjoK5KN42LZr18GlBAZo,1246
15
- documente_shared/domain/entities/processing_case.py,sha256=xIU10DSkh_7_1DU_ttx02eS020FOtCL64dp0kf0Hgm8,5026
16
- documente_shared/domain/entities/processing_case_item.py,sha256=rC8tE2qSw8SaOneKrg_cHtdD2WIAvFYht2qwxQdBuBU,7672
17
- documente_shared/domain/entities/processing_event.py,sha256=m1O0gcNaE_SszeIhxM3uYPHSpyOUmize6mfRw1_bYZo,1723
18
- documente_shared/domain/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- documente_shared/domain/enums/common.py,sha256=vXldMUPhhWo0PfTgYwDSjI8bur_lYcImZYiV7yAO7DQ,2262
20
- documente_shared/domain/enums/document.py,sha256=NltZA1YVgJ7dVfSQdJFIE0ZUGf9Y-nxNXsVQ6GiPLL4,1827
21
- documente_shared/domain/enums/processing_case.py,sha256=DLVk0VnVzrKs1CvXVGHV9p8mBUHLUrOSJJ1POE-Ek3o,1546
22
- documente_shared/domain/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- documente_shared/domain/repositories/document.py,sha256=vJzr6c92gqBzyhaEdjrvnoneKRrWmJ0AsvocPnhxiLU,767
24
- documente_shared/domain/repositories/processing_case.py,sha256=7WE5RdLr04ysGXAdkJYmbfcLpMyOMeuDJGounZKMZqs,729
25
- documente_shared/domain/repositories/processing_case_item.py,sha256=yD-v_24UzHwNdq75KRJGwHemTVFpO9LMIPSup4GbyKs,959
26
- documente_shared/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- documente_shared/infrastructure/dynamo_table.py,sha256=TMQbcuty7wjDMbuhI8PbT0IGXelgELsNTtqTEQeZ824,2112
28
- documente_shared/infrastructure/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- documente_shared/infrastructure/repositories/dynamo_document.py,sha256=_Yp4gtA-n-hJ2w2wAM5BMCs2Mf46Q2Kq3eHqlxudkL4,1443
30
- documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=Wt0di0402mrnvYNqe5ywDtFFdXjnHHvLDG4k_MQfmTE,1401
31
- documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha256=gG7H7hyeKTPMywTUmnq0nClrpaOqVPy7bh1OLBzV4pE,1816
32
- documente_shared/infrastructure/s3_bucket.py,sha256=vT_yN42RFQXubtUn8ln-j13Os_-25UGClVtXg5Bkv6I,1932
33
- documente_shared/infrastructure/sqs_queue.py,sha256=KZWeHZ9zmXmrxoNpOQX7GEdDhZ1knbPXgwSwFwJblGg,1504
34
- documente_shared-0.1.71.dist-info/METADATA,sha256=3TPrU9cuz9uYXEg7_sJer4h_bRt6p19Zmx1WHCbxbSw,839
35
- documente_shared-0.1.71.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
36
- documente_shared-0.1.71.dist-info/RECORD,,