documente_shared 0.1.72__py3-none-any.whl → 0.1.72b0__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.

Files changed (41) hide show
  1. documente_shared/__init__.py +0 -0
  2. documente_shared/application/__init__.py +0 -0
  3. documente_shared/application/digest.py +7 -7
  4. documente_shared/application/exceptions.py +23 -23
  5. documente_shared/application/files.py +22 -22
  6. documente_shared/application/time_utils.py +13 -13
  7. documente_shared/application/timezone.py +7 -7
  8. documente_shared/domain/__init__.py +0 -0
  9. documente_shared/domain/base_enum.py +53 -53
  10. documente_shared/domain/constants.py +2 -2
  11. documente_shared/domain/entities/__init__.py +0 -0
  12. documente_shared/domain/entities/document.py +348 -348
  13. documente_shared/domain/entities/document_metadata.py +63 -63
  14. documente_shared/domain/entities/in_memory_result.py +51 -51
  15. documente_shared/domain/entities/processing_case.py +144 -144
  16. documente_shared/domain/entities/processing_case_item.py +216 -216
  17. documente_shared/domain/entities/processing_event.py +49 -49
  18. documente_shared/domain/enums/__init__.py +0 -0
  19. documente_shared/domain/enums/common.py +95 -95
  20. documente_shared/domain/enums/document.py +71 -71
  21. documente_shared/domain/enums/processing_case.py +54 -54
  22. documente_shared/domain/repositories/__init__.py +0 -0
  23. documente_shared/domain/repositories/document.py +24 -24
  24. documente_shared/domain/repositories/processing_case.py +24 -24
  25. documente_shared/domain/repositories/processing_case_item.py +29 -29
  26. documente_shared/infrastructure/__init__.py +0 -0
  27. documente_shared/infrastructure/documente_client.py +21 -0
  28. documente_shared/infrastructure/dynamo_table.py +75 -75
  29. documente_shared/infrastructure/repositories/__init__.py +0 -0
  30. documente_shared/infrastructure/repositories/dynamo_document.py +43 -43
  31. documente_shared/infrastructure/repositories/dynamo_processing_case.py +43 -43
  32. documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +53 -53
  33. documente_shared/infrastructure/repositories/http_document_processing.py +41 -0
  34. documente_shared/infrastructure/repositories/http_processing_case.py +41 -0
  35. documente_shared/infrastructure/repositories/http_processing_case_item.py +53 -0
  36. documente_shared/infrastructure/s3_bucket.py +57 -57
  37. documente_shared/infrastructure/sqs_queue.py +47 -47
  38. {documente_shared-0.1.72.dist-info → documente_shared-0.1.72b0.dist-info}/METADATA +2 -1
  39. documente_shared-0.1.72b0.dist-info/RECORD +40 -0
  40. documente_shared-0.1.72.dist-info/RECORD +0 -36
  41. {documente_shared-0.1.72.dist-info → documente_shared-0.1.72b0.dist-info}/WHEEL +0 -0
File without changes
File without changes
@@ -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()
@@ -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
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
- import pytz
2
-
1
+ import pytz
2
+
3
3
  la_paz_tz = pytz.timezone("America/La_Paz")
File without changes