documente_shared 0.1.99__tar.gz → 0.1.100__tar.gz
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-0.1.99 → documente_shared-0.1.100}/PKG-INFO +1 -1
- documente_shared-0.1.100/documente_shared/domain/entities/in_memory_document.py +69 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/pyproject.toml +1 -1
- documente_shared-0.1.99/documente_shared/domain/entities/in_memory_document.py +0 -65
- {documente_shared-0.1.99 → documente_shared-0.1.100}/README.md +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/dates.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/digest.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/exceptions.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/files.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/payloads.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/query_params.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/time_utils.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/timezone.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/base_enum.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/constants.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/document.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/document_metadata.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/processing_case.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/processing_case_filters.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/processing_case_item.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/processing_case_item_filters.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/processing_event.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/scaling.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/enums/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/enums/common.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/enums/document.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/enums/processing_case.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/exceptions.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/interfaces/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/interfaces/scaling.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/repositories/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/repositories/document.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/repositories/processing_case.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/repositories/processing_case_item.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/documente_client.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/dynamo_table.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/lambdas.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/dynamo_document.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/dynamo_processing_case.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/http_document_processing.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/http_processing_case.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/http_processing_case_item.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/mem_document.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/mem_processing_case.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/s3_bucket.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/services/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/services/http_scaling.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/sqs_queue.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/presentation/__init__.py +0 -0
- {documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/presentation/presenters.py +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
from documente_shared.application.files import get_filename_from_path
|
|
6
|
+
from documente_shared.domain.exceptions import InMemoryDocumentContentError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class InMemoryDocument(object):
|
|
11
|
+
file_path: Optional[str] = None
|
|
12
|
+
file_bytes: Optional[bytes] = None
|
|
13
|
+
file_base64: Optional[str] = None
|
|
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
|
+
|
|
24
|
+
@property
|
|
25
|
+
def is_valid(self) -> bool:
|
|
26
|
+
return bool(self.file_path and self.file_bytes)
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def has_content(self) -> bool:
|
|
30
|
+
return bool(self.file_bytes or self.file_base64)
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def file_name(self) -> Optional[str]:
|
|
34
|
+
return get_filename_from_path(self.file_path) if self.file_path else None
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def file_key(self) -> Optional[str]:
|
|
38
|
+
return self.file_name
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def is_procesable(self) -> bool:
|
|
42
|
+
return self.is_valid and self.has_content
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def to_dict(self) -> dict:
|
|
46
|
+
return {
|
|
47
|
+
"file_path": self.file_path,
|
|
48
|
+
"file_base64": self.file_base64,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def from_dict(cls, data: dict):
|
|
53
|
+
file_bytes = data.get("file_bytes")
|
|
54
|
+
file_base64 = data.get("file_base64")
|
|
55
|
+
|
|
56
|
+
if not file_bytes and not file_base64:
|
|
57
|
+
raise InMemoryDocumentContentError
|
|
58
|
+
|
|
59
|
+
if file_bytes and not file_base64:
|
|
60
|
+
file_base64 = base64.b64encode(file_bytes).decode()
|
|
61
|
+
|
|
62
|
+
if file_base64 and not file_bytes:
|
|
63
|
+
file_bytes = base64.b64decode(file_base64)
|
|
64
|
+
|
|
65
|
+
return cls(
|
|
66
|
+
file_path=data.get("file_path"),
|
|
67
|
+
file_bytes=file_bytes,
|
|
68
|
+
file_base64=file_base64,
|
|
69
|
+
)
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
from typing import Optional
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
|
|
5
|
-
from documente_shared.application.files import (
|
|
6
|
-
remove_slash_from_path,
|
|
7
|
-
get_filename_from_path,
|
|
8
|
-
)
|
|
9
|
-
from documente_shared.domain.exceptions import InMemoryDocumentContentError
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@dataclass
|
|
13
|
-
class InMemoryDocument(object):
|
|
14
|
-
file_path: Optional[str] = None
|
|
15
|
-
file_bytes: Optional[bytes] = None
|
|
16
|
-
file_base64: Optional[str] = None
|
|
17
|
-
|
|
18
|
-
@property
|
|
19
|
-
def is_valid(self) -> bool:
|
|
20
|
-
return bool(self.file_path) and self.file_bytes
|
|
21
|
-
|
|
22
|
-
@property
|
|
23
|
-
def has_content(self) -> bool:
|
|
24
|
-
return bool(self.file_bytes) or bool(self.file_base64)
|
|
25
|
-
|
|
26
|
-
@property
|
|
27
|
-
def file_name(self) -> Optional[str]:
|
|
28
|
-
if not self.file_path:
|
|
29
|
-
return None
|
|
30
|
-
return get_filename_from_path(self.file_path)
|
|
31
|
-
|
|
32
|
-
@property
|
|
33
|
-
def file_key(self) -> Optional[str]:
|
|
34
|
-
return self.file_name
|
|
35
|
-
|
|
36
|
-
@property
|
|
37
|
-
def is_procesable(self) -> bool:
|
|
38
|
-
return self.is_valid and self.has_content
|
|
39
|
-
|
|
40
|
-
@property
|
|
41
|
-
def to_dict(self) -> dict:
|
|
42
|
-
return {
|
|
43
|
-
"file_path": self.file_path,
|
|
44
|
-
"file_base64": self.file_base64,
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@classmethod
|
|
48
|
-
def from_dict(cls, data: dict):
|
|
49
|
-
has_bytes_content = data.get('file_bytes') and isinstance(data['file_bytes'], bytes)
|
|
50
|
-
has_base64_content = data.get('file_base64') and isinstance(data['file_base64'], str)
|
|
51
|
-
|
|
52
|
-
if not has_bytes_content and not has_base64_content:
|
|
53
|
-
raise InMemoryDocumentContentError
|
|
54
|
-
|
|
55
|
-
if has_bytes_content and not data.get('file_base64'):
|
|
56
|
-
data['file_base64'] = base64.b64encode(data.get('file_bytes')).decode("utf-8")
|
|
57
|
-
|
|
58
|
-
if has_base64_content and not data.get('file_bytes'):
|
|
59
|
-
data['file_bytes'] = base64.b64decode(data.get('file_base64'))
|
|
60
|
-
|
|
61
|
-
return cls(
|
|
62
|
-
file_path=data.get('file_path'),
|
|
63
|
-
file_bytes=data.get('file_bytes'),
|
|
64
|
-
file_base64=data.get('file_base64'),
|
|
65
|
-
)
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/payloads.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/query_params.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/time_utils.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/application/timezone.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/document.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/entities/scaling.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/enums/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/enums/common.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/enums/document.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/interfaces/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/domain/interfaces/scaling.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/dynamo_table.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/lambdas.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/s3_bucket.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/infrastructure/sqs_queue.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/presentation/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.99 → documente_shared-0.1.100}/documente_shared/presentation/presenters.py
RENAMED
|
File without changes
|