documente_shared 0.1.72b0__tar.gz → 0.1.73__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.72b0 → documente_shared-0.1.73}/PKG-INFO +1 -1
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/README.md +16 -16
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/__init__.py +0 -0
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/__init__.py +0 -0
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/digest.py +7 -7
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/exceptions.py +23 -23
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/files.py +22 -22
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/time_utils.py +13 -13
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/timezone.py +7 -7
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/__init__.py +0 -0
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/base_enum.py +53 -53
- documente_shared-0.1.73/documente_shared/domain/constants.py +8 -0
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/entities/__init__.py +0 -0
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/entities/document.py +348 -348
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/entities/document_metadata.py +63 -63
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/entities/in_memory_result.py +51 -51
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/entities/processing_case.py +145 -144
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/entities/processing_case_item.py +216 -216
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/entities/processing_event.py +49 -49
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/enums/__init__.py +0 -0
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/enums/common.py +95 -95
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/enums/document.py +71 -71
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/enums/processing_case.py +55 -54
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/repositories/__init__.py +0 -0
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/repositories/document.py +24 -24
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/repositories/processing_case.py +24 -24
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/repositories/processing_case_item.py +29 -29
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/__init__.py +0 -0
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/documente_client.py +20 -20
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/dynamo_table.py +75 -75
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/repositories/__init__.py +0 -0
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/repositories/dynamo_document.py +43 -43
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/repositories/dynamo_processing_case.py +43 -43
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +53 -53
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/repositories/http_processing_case.py +40 -40
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/repositories/http_processing_case_item.py +52 -52
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/s3_bucket.py +57 -57
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/infrastructure/sqs_queue.py +47 -47
- {documente_shared-0.1.72b0 → documente_shared-0.1.73}/pyproject.toml +40 -40
- documente_shared-0.1.72b0/documente_shared/domain/constants.py +0 -3
- documente_shared-0.1.72b0/documente_shared/infrastructure/repositories/http_document_processing.py +0 -41
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
# Documente Shared
|
|
3
|
-
|
|
4
|
-
Utilidades para proyectos Documente AI
|
|
5
|
-
|
|
6
|
-
## Instalación
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
make build
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Publicación
|
|
13
|
-
Publica `documente-shared` en PyPi
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
make publish
|
|
1
|
+
|
|
2
|
+
# Documente Shared
|
|
3
|
+
|
|
4
|
+
Utilidades para proyectos Documente AI
|
|
5
|
+
|
|
6
|
+
## Instalación
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
make build
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Publicación
|
|
13
|
+
Publica `documente-shared` en PyPi
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
make publish
|
|
17
17
|
```
|
|
File without changes
|
{documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/digest.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import hashlib
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def get_file_digest(file_bytes: bytes) -> str:
|
|
5
|
-
sha256_hash = hashlib.sha256()
|
|
6
|
-
sha256_hash.update(file_bytes)
|
|
7
|
-
return sha256_hash.hexdigest()
|
|
1
|
+
import hashlib
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def get_file_digest(file_bytes: bytes) -> str:
|
|
5
|
+
sha256_hash = hashlib.sha256()
|
|
6
|
+
sha256_hash.update(file_bytes)
|
|
7
|
+
return sha256_hash.hexdigest()
|
{documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/exceptions.py
RENAMED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import sentry_sdk
|
|
2
|
-
from functools import wraps
|
|
3
|
-
from typing import Callable, Any, TypeVar
|
|
4
|
-
|
|
5
|
-
F = TypeVar("F", bound=Callable[..., Any])
|
|
6
|
-
|
|
7
|
-
def initialize_sentry(dsn: str, environment: str = 'dev') -> None:
|
|
8
|
-
if not sentry_sdk.Hub.current.client:
|
|
9
|
-
sentry_sdk.init(
|
|
10
|
-
dsn=dsn,
|
|
11
|
-
environment=environment,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
def track_exceptions(func: F) -> F:
|
|
15
|
-
@wraps(func)
|
|
16
|
-
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
17
|
-
try:
|
|
18
|
-
return func(*args, **kwargs)
|
|
19
|
-
except Exception as e:
|
|
20
|
-
sentry_sdk.capture_exception(e)
|
|
21
|
-
sentry_sdk.flush()
|
|
22
|
-
raise
|
|
23
|
-
return wrapper # type: ignore
|
|
1
|
+
import sentry_sdk
|
|
2
|
+
from functools import wraps
|
|
3
|
+
from typing import Callable, Any, TypeVar
|
|
4
|
+
|
|
5
|
+
F = TypeVar("F", bound=Callable[..., Any])
|
|
6
|
+
|
|
7
|
+
def initialize_sentry(dsn: str, environment: str = 'dev') -> None:
|
|
8
|
+
if not sentry_sdk.Hub.current.client:
|
|
9
|
+
sentry_sdk.init(
|
|
10
|
+
dsn=dsn,
|
|
11
|
+
environment=environment,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
def track_exceptions(func: F) -> F:
|
|
15
|
+
@wraps(func)
|
|
16
|
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
17
|
+
try:
|
|
18
|
+
return func(*args, **kwargs)
|
|
19
|
+
except Exception as e:
|
|
20
|
+
sentry_sdk.capture_exception(e)
|
|
21
|
+
sentry_sdk.flush()
|
|
22
|
+
raise
|
|
23
|
+
return wrapper # type: ignore
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
from os import path
|
|
2
|
-
from typing import Tuple, Optional
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def split_file_params(filepath: str) -> Tuple[str, str, str]:
|
|
6
|
-
folder_path = path.dirname(filepath)
|
|
7
|
-
filename = path.splitext(path.basename(filepath))[0]
|
|
8
|
-
extension = path.splitext(filepath)[1]
|
|
9
|
-
extension = extension.replace('.', '')
|
|
10
|
-
return folder_path, filename, extension
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def get_filename_from_path(file_path: Optional[str]) -> Optional[str]:
|
|
14
|
-
if not file_path:
|
|
15
|
-
return None
|
|
16
|
-
return path.basename(file_path)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def remove_slash_from_path(file_path: str) -> str:
|
|
20
|
-
if file_path and file_path.startswith('/'):
|
|
21
|
-
return file_path[1:]
|
|
22
|
-
return file_path
|
|
1
|
+
from os import path
|
|
2
|
+
from typing import Tuple, Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def split_file_params(filepath: str) -> Tuple[str, str, str]:
|
|
6
|
+
folder_path = path.dirname(filepath)
|
|
7
|
+
filename = path.splitext(path.basename(filepath))[0]
|
|
8
|
+
extension = path.splitext(filepath)[1]
|
|
9
|
+
extension = extension.replace('.', '')
|
|
10
|
+
return folder_path, filename, extension
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_filename_from_path(file_path: Optional[str]) -> Optional[str]:
|
|
14
|
+
if not file_path:
|
|
15
|
+
return None
|
|
16
|
+
return path.basename(file_path)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def remove_slash_from_path(file_path: str) -> str:
|
|
20
|
+
if file_path and file_path.startswith('/'):
|
|
21
|
+
return file_path[1:]
|
|
22
|
+
return file_path
|
{documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/time_utils.py
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
from typing import Union, Optional
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def get_datetime_from_data(input_datetime: Union[datetime, str]) -> Optional[datetime]:
|
|
6
|
-
if isinstance(input_datetime, datetime):
|
|
7
|
-
return input_datetime
|
|
8
|
-
elif isinstance(input_datetime, str) and bool(input_datetime):
|
|
9
|
-
try:
|
|
10
|
-
return datetime.fromisoformat(input_datetime)
|
|
11
|
-
except ValueError:
|
|
12
|
-
return None
|
|
13
|
-
return None
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Union, Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def get_datetime_from_data(input_datetime: Union[datetime, str]) -> Optional[datetime]:
|
|
6
|
+
if isinstance(input_datetime, datetime):
|
|
7
|
+
return input_datetime
|
|
8
|
+
elif isinstance(input_datetime, str) and bool(input_datetime):
|
|
9
|
+
try:
|
|
10
|
+
return datetime.fromisoformat(input_datetime)
|
|
11
|
+
except ValueError:
|
|
12
|
+
return None
|
|
13
|
+
return None
|
{documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/application/timezone.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
from datetime import datetime, timezone
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def ensure_timezone(dt: datetime, tz=timezone.utc) -> datetime:
|
|
5
|
-
if dt.tzinfo is None:
|
|
6
|
-
return dt.replace(tzinfo=tz)
|
|
7
|
-
return dt
|
|
1
|
+
from datetime import datetime, timezone
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def ensure_timezone(dt: datetime, tz=timezone.utc) -> datetime:
|
|
5
|
+
if dt.tzinfo is None:
|
|
6
|
+
return dt.replace(tzinfo=tz)
|
|
7
|
+
return dt
|
|
File without changes
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
from enum import Enum
|
|
2
|
-
from typing import Union, Optional
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class BaseEnum(Enum):
|
|
6
|
-
"""Provides the common functionalties to multiple model choices."""
|
|
7
|
-
|
|
8
|
-
@classmethod
|
|
9
|
-
def get_members(cls):
|
|
10
|
-
return [tag for tag in cls if type(tag.value) in [int, str, float]]
|
|
11
|
-
|
|
12
|
-
@classmethod
|
|
13
|
-
def choices(cls):
|
|
14
|
-
"""Generate choice options for models."""
|
|
15
|
-
return [
|
|
16
|
-
(option.value, option.value)
|
|
17
|
-
for option in cls
|
|
18
|
-
if type(option.value) in [int, str, float]
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
@classmethod
|
|
22
|
-
def values(cls):
|
|
23
|
-
"""Returns values from choices."""
|
|
24
|
-
return [option.value for option in cls]
|
|
25
|
-
|
|
26
|
-
def __str__(self): # noqa: D105
|
|
27
|
-
return str(self.value)
|
|
28
|
-
|
|
29
|
-
def __repr__(self):
|
|
30
|
-
return self.__str__()
|
|
31
|
-
|
|
32
|
-
def __hash__(self):
|
|
33
|
-
return hash(self.value)
|
|
34
|
-
|
|
35
|
-
@classmethod
|
|
36
|
-
def as_list(cls):
|
|
37
|
-
"""Returns properties as a list."""
|
|
38
|
-
return [
|
|
39
|
-
value
|
|
40
|
-
for key, value in cls.__dict__.items()
|
|
41
|
-
if isinstance(value, str) and not key.startswith('__')
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
@classmethod
|
|
45
|
-
def from_value(
|
|
46
|
-
cls,
|
|
47
|
-
value: Union[str, int],
|
|
48
|
-
) -> Optional['BaseEnum']:
|
|
49
|
-
for tag in cls:
|
|
50
|
-
if isinstance(tag.value, str) and str(tag.value).upper() == str(value).upper():
|
|
51
|
-
return tag
|
|
52
|
-
elif not isinstance(tag.value, str) and tag.value == value:
|
|
53
|
-
return tag
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from typing import Union, Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class BaseEnum(Enum):
|
|
6
|
+
"""Provides the common functionalties to multiple model choices."""
|
|
7
|
+
|
|
8
|
+
@classmethod
|
|
9
|
+
def get_members(cls):
|
|
10
|
+
return [tag for tag in cls if type(tag.value) in [int, str, float]]
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def choices(cls):
|
|
14
|
+
"""Generate choice options for models."""
|
|
15
|
+
return [
|
|
16
|
+
(option.value, option.value)
|
|
17
|
+
for option in cls
|
|
18
|
+
if type(option.value) in [int, str, float]
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
@classmethod
|
|
22
|
+
def values(cls):
|
|
23
|
+
"""Returns values from choices."""
|
|
24
|
+
return [option.value for option in cls]
|
|
25
|
+
|
|
26
|
+
def __str__(self): # noqa: D105
|
|
27
|
+
return str(self.value)
|
|
28
|
+
|
|
29
|
+
def __repr__(self):
|
|
30
|
+
return self.__str__()
|
|
31
|
+
|
|
32
|
+
def __hash__(self):
|
|
33
|
+
return hash(self.value)
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def as_list(cls):
|
|
37
|
+
"""Returns properties as a list."""
|
|
38
|
+
return [
|
|
39
|
+
value
|
|
40
|
+
for key, value in cls.__dict__.items()
|
|
41
|
+
if isinstance(value, str) and not key.startswith('__')
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def from_value(
|
|
46
|
+
cls,
|
|
47
|
+
value: Union[str, int],
|
|
48
|
+
) -> Optional['BaseEnum']:
|
|
49
|
+
for tag in cls:
|
|
50
|
+
if isinstance(tag.value, str) and str(tag.value).upper() == str(value).upper():
|
|
51
|
+
return tag
|
|
52
|
+
elif not isinstance(tag.value, str) and tag.value == value:
|
|
53
|
+
return tag
|
|
54
54
|
return None
|
{documente_shared-0.1.72b0 → documente_shared-0.1.73}/documente_shared/domain/entities/__init__.py
RENAMED
|
File without changes
|