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

@@ -1,10 +1,12 @@
1
- from dataclasses import dataclass
1
+ import base64
2
2
  from typing import Optional
3
+ from dataclasses import dataclass
3
4
 
4
5
  from documente_shared.application.files import (
5
6
  remove_slash_from_path,
6
7
  get_filename_from_path,
7
8
  )
9
+ from documente_shared.domain.exceptions import InMemoryDocumentContentError
8
10
 
9
11
 
10
12
  @dataclass
@@ -48,6 +50,18 @@ class InMemoryDocument(object):
48
50
 
49
51
  @classmethod
50
52
  def from_dict(cls, data: dict):
53
+ has_bytes_content = data.get('file_bytes') and isinstance(data['file_bytes'], bytes)
54
+ has_base64_content = data.get('file_base64') and isinstance(data['file_base64'], str)
55
+
56
+ if not has_bytes_content and not has_base64_content:
57
+ raise InMemoryDocumentContentError
58
+
59
+ if has_bytes_content and not data.get('file_base64'):
60
+ data['file_base64'] = base64.b64encode(data.get('file_bytes')).decode("utf-8")
61
+
62
+ if has_base64_content and not data.get('file_bytes'):
63
+ data['file_bytes'] = base64.b64decode(data.get('file_base64'))
64
+
51
65
  return cls(
52
66
  file_path=data.get('file_path'),
53
67
  file_bytes=data.get('file_bytes'),
@@ -88,9 +88,10 @@ class ProcessingCase(object):
88
88
  def to_dict(self) -> dict:
89
89
  return {
90
90
  'uuid': self.uuid,
91
- 'label': self.name,
91
+ 'tenant_slug': self.tenant_slug,
92
+ 'name': self.name,
92
93
  'status': str(self.status),
93
- 'category': (
94
+ 'case_type': (
94
95
  str(self.case_type)
95
96
  if self.case_type else None
96
97
  ),
@@ -5,7 +5,7 @@ from typing import Optional, List
5
5
 
6
6
  from documente_shared.application.time_utils import get_datetime_from_data
7
7
  from documente_shared.domain.constants import la_paz_tz
8
- from documente_shared.domain.entities.in_memory_result import InMemoryDocument
8
+ from documente_shared.domain.entities.in_memory_document import InMemoryDocument
9
9
  from documente_shared.domain.enums.common import ProcessingStatus, ProcessingSource
10
10
  from documente_shared.domain.enums.processing_case import ProcessingDocumentType
11
11
 
@@ -0,0 +1,5 @@
1
+
2
+
3
+
4
+ class InMemoryDocumentContentError(Exception):
5
+ pass
@@ -0,0 +1,37 @@
1
+ from dataclasses import dataclass
2
+ from typing import List, Optional
3
+
4
+ from documente_shared.domain.entities.document import DocumentProcessing
5
+ from documente_shared.domain.enums.document import DocumentProcessingStatus
6
+ from documente_shared.domain.repositories.document import DocumentProcessingRepository
7
+
8
+
9
+ @dataclass
10
+ class MemoryDocumentProcessingRepository(DocumentProcessingRepository):
11
+ collection: dict[str, DocumentProcessing] = None
12
+
13
+ def __post_init__(self):
14
+ self.collection = self.collection or {}
15
+
16
+ def find(self, digest: str) -> Optional[DocumentProcessing]:
17
+ if digest in self.collection:
18
+ return self.collection[digest]
19
+ return None
20
+
21
+
22
+ def persist(self, instance: DocumentProcessing) -> DocumentProcessing:
23
+ self.collection[instance.digest] = instance
24
+ return instance
25
+
26
+ def remove(self, instance: DocumentProcessing):
27
+ if instance.digest in self.collection:
28
+ del self.collection[instance.digest]
29
+ return None
30
+
31
+ def filter(self, statuses: List[DocumentProcessingStatus]) -> List[DocumentProcessing]:
32
+ items = []
33
+ for status in statuses:
34
+ items.extend(
35
+ [item for item in self.collection.values() if item.status == status]
36
+ )
37
+ return items
@@ -0,0 +1,36 @@
1
+ from dataclasses import dataclass
2
+ from typing import List, Optional
3
+
4
+ from documente_shared.domain.entities.processing_case import ProcessingCase
5
+ from documente_shared.domain.entities.processing_case_filters import ProcessingCaseFilters
6
+
7
+ from documente_shared.domain.repositories.processing_case import ProcessingCaseRepository
8
+
9
+
10
+ @dataclass
11
+ class MemoryProcessingCaseRepository(ProcessingCaseRepository):
12
+ collection: dict[str, ProcessingCase] = None
13
+
14
+ def __post_init__(self):
15
+ self.collection = self.collection or {}
16
+
17
+ def find(
18
+ self,
19
+ uuid: str,
20
+ include_items: bool = False,
21
+ ) -> Optional[ProcessingCase]:
22
+ if uuid in self.collection:
23
+ return self.collection[uuid]
24
+ return None
25
+
26
+ def persist(self, instance: ProcessingCase) -> ProcessingCase:
27
+ self.collection[instance.uuid] = instance
28
+ return instance
29
+
30
+ def remove(self, instance: ProcessingCase):
31
+ if instance.uuid in self.collection:
32
+ del self.collection[instance.uuid]
33
+ return None
34
+
35
+ def filter(self, filters: ProcessingCaseFilters) -> List[ProcessingCase]:
36
+ return []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.96
3
+ Version: 0.1.98
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -14,10 +14,10 @@ documente_shared/domain/constants.py,sha256=NG5BGaXBr_FnzudjTRPxpDpyiSDdaB_PLCdl
14
14
  documente_shared/domain/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  documente_shared/domain/entities/document.py,sha256=xGZdrqqBkbvDbgoxUvIck6FplXjwLcZzFkcEsuh80u8,12819
16
16
  documente_shared/domain/entities/document_metadata.py,sha256=ygyFIC5qwxlm8DUM5kvVFny9zJfPQS8vNLM2br5XsQ8,2353
17
- documente_shared/domain/entities/in_memory_result.py,sha256=0sLNUrovKFQx4M-E9e4DrAiVgch2i4AKA-9BQBRaeI8,1482
18
- documente_shared/domain/entities/processing_case.py,sha256=ocPSvy0owiJq0cWnSHLIlY1UgE6Qz3ys0NwF6IxcMI0,5595
17
+ documente_shared/domain/entities/in_memory_document.py,sha256=mOhylBu1k1Ke7G2NO0UHH7kCVp-H2PTa_4QZCNgUaAA,2161
18
+ documente_shared/domain/entities/processing_case.py,sha256=2wD256_ra5szb8LVmGsauTsFTbkAqT1srOv5zuZQXgA,5640
19
19
  documente_shared/domain/entities/processing_case_filters.py,sha256=harKyu7QEuL1bI_Z8_UxkVCMo5r9vHeNHyi_Ja07vjs,1953
20
- documente_shared/domain/entities/processing_case_item.py,sha256=kYw0YmUjZvWv5SOOxqUlS5pf_Z9s3oCnEYFQl2swSAg,10106
20
+ documente_shared/domain/entities/processing_case_item.py,sha256=VbVOqAUHtcCHfAF5VpG47IWkM8t6eSX4VuDifJe7ZzA,10108
21
21
  documente_shared/domain/entities/processing_case_item_filters.py,sha256=R_AvDCB496Lww1qn2OwtltqULKE3IpcJB0ejnmRkg7Q,2009
22
22
  documente_shared/domain/entities/processing_event.py,sha256=izdBXEz0TMNjxxZVjcM3YclzOv250JOV-amSpqmtQ9c,2180
23
23
  documente_shared/domain/entities/scaling.py,sha256=Me1z3X-5NjzPMX-TBQ4xHwE_44tIJegi1QSCHQRNtx4,745
@@ -25,6 +25,7 @@ documente_shared/domain/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
25
25
  documente_shared/domain/enums/common.py,sha256=wJWYhh98sdCGL_1WodhYLpoT_IYTzkTDOexclpaIM-0,2827
26
26
  documente_shared/domain/enums/document.py,sha256=QwvckW-VJBSujllIVloKlZUh1pI5UnX4oueYbV5CYGw,3205
27
27
  documente_shared/domain/enums/processing_case.py,sha256=nIXtya6lmEOB0uWKkH4hLWOeBa8_BgKshHiMrGweswQ,1673
28
+ documente_shared/domain/exceptions.py,sha256=S2xkkFPiR8jVmA6UhRb-bPVrm6JvohXw2MUhZOzdnRo,58
28
29
  documente_shared/domain/interfaces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
30
  documente_shared/domain/interfaces/scaling.py,sha256=yWAud0rcLKMMf2-QxEE__GRpzqUY0H9_qxlQTfnRYmw,249
30
31
  documente_shared/domain/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -42,12 +43,14 @@ documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha2
42
43
  documente_shared/infrastructure/repositories/http_document_processing.py,sha256=7n4lHgpN17CCr4_Dz9WRbsXeb4FDMJZNDUshFipA1B8,2179
43
44
  documente_shared/infrastructure/repositories/http_processing_case.py,sha256=n1NXJtROTfet2QCKSNnQtLmcNgkJDo6q0Hq48FSpwEU,2249
44
45
  documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=idciRUH3LGbD13TS6BlEpCpC-lWKqf1MssmjcdR3CKU,2971
46
+ documente_shared/infrastructure/repositories/mem_document.py,sha256=jg4rIjgSZijymjY9o7Q1lLcaiW9h-O8j6XljO1bJI7c,1299
47
+ documente_shared/infrastructure/repositories/mem_processing_case.py,sha256=ZAQwp4j0DXQMt92Z-ZR4h9MtbUp9IYy0OHz_sHgkZxY,1147
45
48
  documente_shared/infrastructure/s3_bucket.py,sha256=vT_yN42RFQXubtUn8ln-j13Os_-25UGClVtXg5Bkv6I,1932
46
49
  documente_shared/infrastructure/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
50
  documente_shared/infrastructure/services/http_scaling.py,sha256=cIo-61nfIwbtO86EGi5r1tFi9g3VJXldhguddt4JUyc,906
48
51
  documente_shared/infrastructure/sqs_queue.py,sha256=KZWeHZ9zmXmrxoNpOQX7GEdDhZ1knbPXgwSwFwJblGg,1504
49
52
  documente_shared/presentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
53
  documente_shared/presentation/presenters.py,sha256=GGAEwefmjCIVepsUA2oZOVLxXbhhiISPM0Jgt6dT6O0,423
51
- documente_shared-0.1.96.dist-info/METADATA,sha256=nWhol-EMMx-ilLt_ga76hGdF5bdlDsc4V0_8GcZSahU,920
52
- documente_shared-0.1.96.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
53
- documente_shared-0.1.96.dist-info/RECORD,,
54
+ documente_shared-0.1.98.dist-info/METADATA,sha256=KSDKIiBBkgAI5X4O7h0kad0DhXm9CgLqxCzP3-EVRN0,920
55
+ documente_shared-0.1.98.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
56
+ documente_shared-0.1.98.dist-info/RECORD,,