documente_shared 0.1.99__py3-none-any.whl → 0.1.101__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.
- documente_shared/domain/entities/in_memory_document.py +23 -19
- documente_shared/domain/entities/processing_documents.py +11 -0
- {documente_shared-0.1.99.dist-info → documente_shared-0.1.101.dist-info}/METADATA +1 -1
- {documente_shared-0.1.99.dist-info → documente_shared-0.1.101.dist-info}/RECORD +5 -4
- {documente_shared-0.1.99.dist-info → documente_shared-0.1.101.dist-info}/WHEEL +0 -0
|
@@ -2,10 +2,7 @@ import base64
|
|
|
2
2
|
from typing import Optional
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
|
|
5
|
-
from documente_shared.application.files import
|
|
6
|
-
remove_slash_from_path,
|
|
7
|
-
get_filename_from_path,
|
|
8
|
-
)
|
|
5
|
+
from documente_shared.application.files import get_filename_from_path
|
|
9
6
|
from documente_shared.domain.exceptions import InMemoryDocumentContentError
|
|
10
7
|
|
|
11
8
|
|
|
@@ -15,19 +12,26 @@ class InMemoryDocument(object):
|
|
|
15
12
|
file_bytes: Optional[bytes] = None
|
|
16
13
|
file_base64: Optional[str] = None
|
|
17
14
|
|
|
15
|
+
def __post_init__(self):
|
|
16
|
+
if not self.file_path:
|
|
17
|
+
return
|
|
18
|
+
if self.file_base64 and not self.file_bytes:
|
|
19
|
+
self.file_bytes = base64.b64decode(self.file_base64)
|
|
20
|
+
elif self.file_bytes and not self.file_base64:
|
|
21
|
+
self.file_base64 = base64.b64encode(self.file_bytes).decode()
|
|
22
|
+
|
|
23
|
+
|
|
18
24
|
@property
|
|
19
25
|
def is_valid(self) -> bool:
|
|
20
|
-
return bool(self.file_path
|
|
26
|
+
return bool(self.file_path and self.file_bytes)
|
|
21
27
|
|
|
22
28
|
@property
|
|
23
29
|
def has_content(self) -> bool:
|
|
24
|
-
return bool(self.file_bytes
|
|
30
|
+
return bool(self.file_bytes or self.file_base64)
|
|
25
31
|
|
|
26
32
|
@property
|
|
27
33
|
def file_name(self) -> Optional[str]:
|
|
28
|
-
if
|
|
29
|
-
return None
|
|
30
|
-
return get_filename_from_path(self.file_path)
|
|
34
|
+
return get_filename_from_path(self.file_path) if self.file_path else None
|
|
31
35
|
|
|
32
36
|
@property
|
|
33
37
|
def file_key(self) -> Optional[str]:
|
|
@@ -46,20 +50,20 @@ class InMemoryDocument(object):
|
|
|
46
50
|
|
|
47
51
|
@classmethod
|
|
48
52
|
def from_dict(cls, data: dict):
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
file_bytes = data.get("file_bytes")
|
|
54
|
+
file_base64 = data.get("file_base64")
|
|
51
55
|
|
|
52
|
-
if not
|
|
56
|
+
if not file_bytes and not file_base64:
|
|
53
57
|
raise InMemoryDocumentContentError
|
|
54
58
|
|
|
55
|
-
if
|
|
56
|
-
|
|
59
|
+
if file_bytes and not file_base64:
|
|
60
|
+
file_base64 = base64.b64encode(file_bytes).decode()
|
|
57
61
|
|
|
58
|
-
if
|
|
59
|
-
|
|
62
|
+
if file_base64 and not file_bytes:
|
|
63
|
+
file_bytes = base64.b64decode(file_base64)
|
|
60
64
|
|
|
61
65
|
return cls(
|
|
62
|
-
file_path=data.get(
|
|
63
|
-
file_bytes=
|
|
64
|
-
file_base64=
|
|
66
|
+
file_path=data.get("file_path"),
|
|
67
|
+
file_bytes=file_bytes,
|
|
68
|
+
file_base64=file_base64,
|
|
65
69
|
)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from documente_shared.domain.entities.in_memory_document import InMemoryDocument
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class ProcessedDocuments(object):
|
|
9
|
+
processed_csv: Optional[InMemoryDocument] = None
|
|
10
|
+
processed_xlsx: Optional[InMemoryDocument] = None
|
|
11
|
+
processed_json: Optional[InMemoryDocument] = None
|
|
@@ -14,11 +14,12 @@ 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_document.py,sha256=
|
|
17
|
+
documente_shared/domain/entities/in_memory_document.py,sha256=5MFG5V4EtNr-wwrLEFZusZPWvla52g5wuI6es5nQ4tM,1999
|
|
18
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
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
|
+
documente_shared/domain/entities/processing_documents.py,sha256=YYuTkdCNkqlO8cA0onJsZYtstxGt9M5NMuIO_87lB14,352
|
|
22
23
|
documente_shared/domain/entities/processing_event.py,sha256=izdBXEz0TMNjxxZVjcM3YclzOv250JOV-amSpqmtQ9c,2180
|
|
23
24
|
documente_shared/domain/entities/scaling.py,sha256=Me1z3X-5NjzPMX-TBQ4xHwE_44tIJegi1QSCHQRNtx4,745
|
|
24
25
|
documente_shared/domain/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -51,6 +52,6 @@ documente_shared/infrastructure/services/http_scaling.py,sha256=cIo-61nfIwbtO86E
|
|
|
51
52
|
documente_shared/infrastructure/sqs_queue.py,sha256=KZWeHZ9zmXmrxoNpOQX7GEdDhZ1knbPXgwSwFwJblGg,1504
|
|
52
53
|
documente_shared/presentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
54
|
documente_shared/presentation/presenters.py,sha256=GGAEwefmjCIVepsUA2oZOVLxXbhhiISPM0Jgt6dT6O0,423
|
|
54
|
-
documente_shared-0.1.
|
|
55
|
-
documente_shared-0.1.
|
|
56
|
-
documente_shared-0.1.
|
|
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,,
|
|
File without changes
|