documente_shared 0.1.101__py3-none-any.whl → 0.1.103__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.

@@ -0,0 +1,45 @@
1
+ import re
2
+ from typing import Any
3
+
4
+ import unicodedata
5
+ from unidecode import unidecode
6
+
7
+
8
+ def underscoreize(data: Any) -> Any:
9
+ if isinstance(data, dict):
10
+ new_dict = {}
11
+ for key, value in data.items():
12
+ new_key = re.sub(r"(?<!^)(?=[A-Z])", "_", key).lower()
13
+ new_dict[new_key] = underscoreize(value)
14
+ return new_dict
15
+ elif isinstance(data, list):
16
+ return [underscoreize(item) for item in data]
17
+ else:
18
+ return data
19
+
20
+
21
+ def safe_format(data: Any) -> Any:
22
+ if isinstance(data, dict):
23
+ new_dict = {}
24
+ for key, value in data.items():
25
+ new_key = unidecode(key.replace(" ", "_"))
26
+ new_dict[new_key] = safe_format(value)
27
+ return new_dict
28
+ elif isinstance(data, list):
29
+ return [safe_format(item) for item in data]
30
+ else:
31
+ return data
32
+
33
+
34
+ def normalize_key(key: str) -> str:
35
+ normalized = unicodedata.normalize('NFC', key)
36
+ underscored = re.sub(r'\s+', '_', normalized)
37
+ return underscored
38
+
39
+
40
+ def normalize_dict_keys(data: dict) -> dict:
41
+ return {normalize_key(k): v for k, v in data.items()}
42
+
43
+
44
+ def normalize_list_keys(data: list) -> list:
45
+ return [normalize_dict_keys(item) for item in data]
@@ -20,9 +20,9 @@ from documente_shared.domain.enums.document import (
20
20
  class DocumentProcessing(object):
21
21
  digest: str
22
22
  status: DocumentProcessingStatus
23
+ category: DocumentProcessingCategory
23
24
  file_path: Optional[str] = None
24
25
  file_bytes: Optional[bytes] = None
25
- category: Optional[DocumentProcessingCategory] = None
26
26
  sub_category: Optional[DocumentProcessingSubCategory] = None
27
27
  uploaded_from: Optional[DocumentProcessingSource] = None
28
28
  processed_csv_path: Optional[str] = None
@@ -48,6 +48,10 @@ class DocumentProcessing(object):
48
48
  def __post_init__(self):
49
49
  self.metadata_items = self.metadata_items or []
50
50
 
51
+ @property
52
+ def strategy_id(self) -> str:
53
+ return str(self.category)
54
+
51
55
  @property
52
56
  def is_pending(self) -> bool:
53
57
  return self.status == DocumentProcessingStatus.PENDING
@@ -15,7 +15,7 @@ class ProcessingCase(object):
15
15
  name: str
16
16
  tenant_slug: str
17
17
  status: ProcessingStatus
18
- case_type: Optional[ProcessingCaseType] = None
18
+ case_type: ProcessingCaseType
19
19
  enqueued_at: Optional[datetime] = None
20
20
  started_at: Optional[datetime] = None
21
21
  failed_at: Optional[datetime] = None
@@ -27,6 +27,10 @@ class ProcessingCase(object):
27
27
  def __post_init__(self):
28
28
  self.items = self.items or []
29
29
 
30
+ @property
31
+ def strategy_id(self) ->str:
32
+ return str(self.case_type)
33
+
30
34
  @property
31
35
  def is_procesable(self) -> bool:
32
36
  return self.items and len(self.items) > 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.101
3
+ Version: 0.1.103
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -17,6 +17,7 @@ Requires-Dist: loguru (>=0.7.3,<0.8.0)
17
17
  Requires-Dist: pytz (>=2025.2,<2026.0)
18
18
  Requires-Dist: requests (>=2.32.3,<3.0.0)
19
19
  Requires-Dist: sentry-sdk (>=2.19.2,<3.0.0)
20
+ Requires-Dist: unidecode (>=1.3.8,<2.0.0)
20
21
  Description-Content-Type: text/markdown
21
22
 
22
23
 
@@ -4,6 +4,7 @@ documente_shared/application/dates.py,sha256=uExNddWmX9VEX_u420JGoC7fL-ieJ4956I0
4
4
  documente_shared/application/digest.py,sha256=Um6E8WfFri2_lly4RFWydJyvSfPZGFcOX-opEOzDCWc,172
5
5
  documente_shared/application/exceptions.py,sha256=lQM8m7wmI9OTLGva0gd7s7YT7ldaTk_Ln4t32PpzNf8,654
6
6
  documente_shared/application/files.py,sha256=ADiWi6Mk3YQGx3boGsDqdb5wk8qmabkGRy7bhNFa1OY,649
7
+ documente_shared/application/json.py,sha256=5y67-DoiJlq_fLefgJ8YBVsdyua4KykxbSUKQqcwnnQ,1223
7
8
  documente_shared/application/payloads.py,sha256=s6SjaNN18_aQ6IL083Zq2J8thRCZ_zC2sn7hkfjK_Go,453
8
9
  documente_shared/application/query_params.py,sha256=JscPqFBx28p-x9i2g6waY7Yl4FQM1zn2zSbEoTrkK1k,3938
9
10
  documente_shared/application/time_utils.py,sha256=_fxgh8VoGPkdsft47COJ16vFwt8pMbHIJCgDFHLSlrU,435
@@ -12,10 +13,10 @@ documente_shared/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
12
13
  documente_shared/domain/base_enum.py,sha256=DojAfn-zQdtjtImeHUpBzE6TBTm07XrbMOdW3h8RVd8,1449
13
14
  documente_shared/domain/constants.py,sha256=NG5BGaXBr_FnzudjTRPxpDpyiSDdaB_PLCdlYlFUQeU,187
14
15
  documente_shared/domain/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- documente_shared/domain/entities/document.py,sha256=xGZdrqqBkbvDbgoxUvIck6FplXjwLcZzFkcEsuh80u8,12819
16
+ documente_shared/domain/entities/document.py,sha256=2OHn9mNjzqKSpw9fY6xCHIMRw3D4nZmmUTZZj_K4ISc,12885
16
17
  documente_shared/domain/entities/document_metadata.py,sha256=ygyFIC5qwxlm8DUM5kvVFny9zJfPQS8vNLM2br5XsQ8,2353
17
18
  documente_shared/domain/entities/in_memory_document.py,sha256=5MFG5V4EtNr-wwrLEFZusZPWvla52g5wuI6es5nQ4tM,1999
18
- documente_shared/domain/entities/processing_case.py,sha256=2wD256_ra5szb8LVmGsauTsFTbkAqT1srOv5zuZQXgA,5640
19
+ documente_shared/domain/entities/processing_case.py,sha256=NwGGGMyXnNprtO1lCP6rkPbhGhZ6C_z30OeHi_LHXDY,5706
19
20
  documente_shared/domain/entities/processing_case_filters.py,sha256=harKyu7QEuL1bI_Z8_UxkVCMo5r9vHeNHyi_Ja07vjs,1953
20
21
  documente_shared/domain/entities/processing_case_item.py,sha256=VbVOqAUHtcCHfAF5VpG47IWkM8t6eSX4VuDifJe7ZzA,10108
21
22
  documente_shared/domain/entities/processing_case_item_filters.py,sha256=R_AvDCB496Lww1qn2OwtltqULKE3IpcJB0ejnmRkg7Q,2009
@@ -52,6 +53,6 @@ documente_shared/infrastructure/services/http_scaling.py,sha256=cIo-61nfIwbtO86E
52
53
  documente_shared/infrastructure/sqs_queue.py,sha256=KZWeHZ9zmXmrxoNpOQX7GEdDhZ1knbPXgwSwFwJblGg,1504
53
54
  documente_shared/presentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
55
  documente_shared/presentation/presenters.py,sha256=GGAEwefmjCIVepsUA2oZOVLxXbhhiISPM0Jgt6dT6O0,423
55
- documente_shared-0.1.101.dist-info/METADATA,sha256=IZEXi-z2DgZ555MLaBNN86I3Z5aN9s0A4EHOUfH27xc,921
56
- documente_shared-0.1.101.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
57
- documente_shared-0.1.101.dist-info/RECORD,,
56
+ documente_shared-0.1.103.dist-info/METADATA,sha256=Yx5Ple4KfKdy7iklQkofyD4f-m2Iz7f26XETdrO1tFI,963
57
+ documente_shared-0.1.103.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
58
+ documente_shared-0.1.103.dist-info/RECORD,,