documente_shared 0.1.98__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.

Files changed (57) hide show
  1. {documente_shared-0.1.98 → documente_shared-0.1.100}/PKG-INFO +1 -1
  2. documente_shared-0.1.100/documente_shared/domain/entities/in_memory_document.py +69 -0
  3. {documente_shared-0.1.98 → documente_shared-0.1.100}/pyproject.toml +1 -1
  4. documente_shared-0.1.98/documente_shared/domain/entities/in_memory_document.py +0 -69
  5. {documente_shared-0.1.98 → documente_shared-0.1.100}/README.md +0 -0
  6. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/__init__.py +0 -0
  7. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/application/__init__.py +0 -0
  8. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/application/dates.py +0 -0
  9. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/application/digest.py +0 -0
  10. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/application/exceptions.py +0 -0
  11. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/application/files.py +0 -0
  12. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/application/payloads.py +0 -0
  13. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/application/query_params.py +0 -0
  14. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/application/time_utils.py +0 -0
  15. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/application/timezone.py +0 -0
  16. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/__init__.py +0 -0
  17. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/base_enum.py +0 -0
  18. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/constants.py +0 -0
  19. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/entities/__init__.py +0 -0
  20. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/entities/document.py +0 -0
  21. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/entities/document_metadata.py +0 -0
  22. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/entities/processing_case.py +0 -0
  23. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/entities/processing_case_filters.py +0 -0
  24. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/entities/processing_case_item.py +0 -0
  25. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/entities/processing_case_item_filters.py +0 -0
  26. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/entities/processing_event.py +0 -0
  27. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/entities/scaling.py +0 -0
  28. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/enums/__init__.py +0 -0
  29. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/enums/common.py +0 -0
  30. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/enums/document.py +0 -0
  31. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/enums/processing_case.py +0 -0
  32. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/exceptions.py +0 -0
  33. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/interfaces/__init__.py +0 -0
  34. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/interfaces/scaling.py +0 -0
  35. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/repositories/__init__.py +0 -0
  36. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/repositories/document.py +0 -0
  37. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/repositories/processing_case.py +0 -0
  38. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/domain/repositories/processing_case_item.py +0 -0
  39. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/__init__.py +0 -0
  40. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/documente_client.py +0 -0
  41. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/dynamo_table.py +0 -0
  42. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/lambdas.py +0 -0
  43. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/__init__.py +0 -0
  44. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/dynamo_document.py +0 -0
  45. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/dynamo_processing_case.py +0 -0
  46. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +0 -0
  47. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/http_document_processing.py +0 -0
  48. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/http_processing_case.py +0 -0
  49. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/http_processing_case_item.py +0 -0
  50. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/mem_document.py +0 -0
  51. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/repositories/mem_processing_case.py +0 -0
  52. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/s3_bucket.py +0 -0
  53. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/services/__init__.py +0 -0
  54. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/services/http_scaling.py +0 -0
  55. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/infrastructure/sqs_queue.py +0 -0
  56. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/presentation/__init__.py +0 -0
  57. {documente_shared-0.1.98 → documente_shared-0.1.100}/documente_shared/presentation/presenters.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.98
3
+ Version: 0.1.100
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -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,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "documente_shared"
3
- version = "0.1.98"
3
+ version = "0.1.100"
4
4
  description = "Shared utilities for Documente AI projects"
5
5
  authors = ["Tech <tech@llamitai.com>"]
6
6
  license = "MIT"
@@ -1,69 +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
- data = dict()
43
- if self.file_path:
44
- data['file_path'] = remove_slash_from_path(self.file_path)
45
- if self.file_bytes:
46
- data['file_bytes'] = self.file_bytes.decode('utf-8')
47
- if self.file_base64:
48
- data['file_base64'] = self.file_base64
49
- return data
50
-
51
- @classmethod
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
-
65
- return cls(
66
- file_path=data.get('file_path'),
67
- file_bytes=data.get('file_bytes'),
68
- file_base64=data.get('file_base64'),
69
- )