documente_shared 0.1.15__py3-none-any.whl → 0.1.17__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.py +37 -6
- documente_shared/domain/enums.py +10 -0
- documente_shared/domain/repositories.py +5 -0
- documente_shared/infrastructure/dynamo_repositories.py +6 -0
- {documente_shared-0.1.15.dist-info → documente_shared-0.1.17.dist-info}/METADATA +1 -1
- {documente_shared-0.1.15.dist-info → documente_shared-0.1.17.dist-info}/RECORD +7 -7
- {documente_shared-0.1.15.dist-info → documente_shared-0.1.17.dist-info}/WHEEL +0 -0
|
@@ -3,7 +3,11 @@ from datetime import datetime
|
|
|
3
3
|
from decimal import Decimal
|
|
4
4
|
from typing import Optional
|
|
5
5
|
|
|
6
|
-
from documente_shared.domain.enums import
|
|
6
|
+
from documente_shared.domain.enums import (
|
|
7
|
+
DocumentProcessStatus,
|
|
8
|
+
DocumentProcessSubCategory,
|
|
9
|
+
DocumentProcessCategory,
|
|
10
|
+
)
|
|
7
11
|
|
|
8
12
|
|
|
9
13
|
@dataclass
|
|
@@ -11,13 +15,19 @@ class DocumentProcess(object):
|
|
|
11
15
|
digest: str
|
|
12
16
|
status: DocumentProcessStatus
|
|
13
17
|
file_path: str
|
|
18
|
+
file_bytes: Optional[bytes] = None
|
|
19
|
+
category: Optional[DocumentProcessCategory] = None
|
|
20
|
+
sub_category: Optional[DocumentProcessSubCategory] = None
|
|
14
21
|
processed_csv_path: Optional[str] = None
|
|
22
|
+
processed_csv_bytes: Optional[bytes] = None
|
|
15
23
|
processed_xlsx_path: Optional[str] = None
|
|
24
|
+
processed_xlsx_bytes: Optional[bytes] = None
|
|
16
25
|
processing_time: Optional[Decimal] = None
|
|
26
|
+
uploded_at: Optional[datetime] = None
|
|
17
27
|
enqueued_at: Optional[datetime] = None
|
|
18
28
|
started_at: Optional[datetime] = None
|
|
19
29
|
failed_at: Optional[datetime] = None
|
|
20
|
-
|
|
30
|
+
completed_at: Optional[datetime] = None
|
|
21
31
|
|
|
22
32
|
@property
|
|
23
33
|
def is_pending(self) -> bool:
|
|
@@ -61,7 +71,7 @@ class DocumentProcess(object):
|
|
|
61
71
|
|
|
62
72
|
def completed(self):
|
|
63
73
|
self.status = DocumentProcessStatus.COMPLETED
|
|
64
|
-
self.
|
|
74
|
+
self.completed_at = datetime.now()
|
|
65
75
|
|
|
66
76
|
def deleted(self):
|
|
67
77
|
self.status = DocumentProcessStatus.DELETED
|
|
@@ -77,16 +87,25 @@ class DocumentProcess(object):
|
|
|
77
87
|
'digest': self.digest,
|
|
78
88
|
'status': self.status.value,
|
|
79
89
|
'file_path': self.file_path,
|
|
90
|
+
'category': (
|
|
91
|
+
str(self.category)
|
|
92
|
+
if self.category else None
|
|
93
|
+
),
|
|
94
|
+
'sub_category': (
|
|
95
|
+
str(self.sub_category)
|
|
96
|
+
if self.sub_category else None
|
|
97
|
+
),
|
|
80
98
|
'processed_csv_path': self.processed_csv_path,
|
|
81
99
|
'processed_xlsx_path': self.processed_xlsx_path,
|
|
82
100
|
'processing_time': (
|
|
83
101
|
str(self.processing_time)
|
|
84
102
|
if self.processing_time else None
|
|
85
103
|
),
|
|
104
|
+
'uploded_at': self.uploded_at.isoformat() if self.uploded_at else None,
|
|
86
105
|
'enqueued_at': self.enqueued_at.isoformat() if self.enqueued_at else None,
|
|
87
106
|
'started_at': self.started_at.isoformat() if self.started_at else None,
|
|
88
107
|
'failed_at': self.failed_at.isoformat() if self.failed_at else None,
|
|
89
|
-
'
|
|
108
|
+
'completed_at': self.completed_at.isoformat() if self.completed_at else None,
|
|
90
109
|
}
|
|
91
110
|
|
|
92
111
|
@classmethod
|
|
@@ -95,12 +114,24 @@ class DocumentProcess(object):
|
|
|
95
114
|
digest=data.get('digest'),
|
|
96
115
|
status=DocumentProcessStatus.from_value(data.get('status')),
|
|
97
116
|
file_path=data.get('file_path'),
|
|
117
|
+
category=(
|
|
118
|
+
DocumentProcessCategory.from_value(data.get('category'))
|
|
119
|
+
if data.get('category') else None
|
|
120
|
+
),
|
|
121
|
+
sub_category=(
|
|
122
|
+
DocumentProcessSubCategory.from_value(data.get('sub_category'))
|
|
123
|
+
if data.get('sub_category') else None
|
|
124
|
+
),
|
|
98
125
|
processed_csv_path=data.get('processed_csv_path'),
|
|
99
126
|
processed_xlsx_path=data.get('processed_xlsx_path'),
|
|
100
127
|
processing_time=(
|
|
101
128
|
Decimal(data.get('processing_time'))
|
|
102
129
|
if data.get('processing_time') else None
|
|
103
130
|
),
|
|
131
|
+
uploded_at=(
|
|
132
|
+
datetime.fromisoformat(data.get('uploded_at'))
|
|
133
|
+
if data.get('uploded_at') else None
|
|
134
|
+
),
|
|
104
135
|
enqueued_at=(
|
|
105
136
|
datetime.fromisoformat(data.get('enqueued_at'))
|
|
106
137
|
if data.get('enqueued_at') else None
|
|
@@ -113,8 +144,8 @@ class DocumentProcess(object):
|
|
|
113
144
|
datetime.fromisoformat(data.get('failed_at'))
|
|
114
145
|
if data.get('failed_at') else None
|
|
115
146
|
),
|
|
116
|
-
|
|
117
|
-
datetime.fromisoformat(data.get('
|
|
147
|
+
completed_at=(
|
|
148
|
+
datetime.fromisoformat(data.get('completed_at'))
|
|
118
149
|
if data.get('processed_at') else None
|
|
119
150
|
),
|
|
120
151
|
)
|
documente_shared/domain/enums.py
CHANGED
|
@@ -9,3 +9,13 @@ class DocumentProcessStatus(BaseEnum):
|
|
|
9
9
|
FAILED = 'FAILED'
|
|
10
10
|
DELETED = 'DELETED'
|
|
11
11
|
|
|
12
|
+
|
|
13
|
+
class DocumentProcessCategory(BaseEnum):
|
|
14
|
+
CIRCULAR = 'CIRCULAR'
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class DocumentProcessSubCategory(BaseEnum):
|
|
18
|
+
CC_COMBINADA = 'CC_COMBINADA'
|
|
19
|
+
CC_NORMATIVA = 'CC_NORMATIVA'
|
|
20
|
+
|
|
21
|
+
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
2
|
|
|
3
3
|
from documente_shared.domain.entities import DocumentProcess
|
|
4
|
+
from python_layer.python.typing_extensions import Optional
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
class DocumentProcessRepository(ABC):
|
|
7
8
|
|
|
9
|
+
@abstractmethod
|
|
10
|
+
def find(self, digest: str) ->Optional[DocumentProcess]:
|
|
11
|
+
raise NotImplementedError
|
|
12
|
+
|
|
8
13
|
@abstractmethod
|
|
9
14
|
def persist(self, instance: DocumentProcess) -> DocumentProcess:
|
|
10
15
|
raise NotImplementedError
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
from documente_shared.domain.entities import DocumentProcess
|
|
2
2
|
from documente_shared.domain.repositories import DocumentProcessRepository
|
|
3
3
|
from documente_shared.infrastructure.dynamo_table import DynamoDBTable
|
|
4
|
+
from python_layer.python.typing_extensions import Optional
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
class DynamoDocumentProcessRepository(
|
|
7
8
|
DynamoDBTable,
|
|
8
9
|
DocumentProcessRepository,
|
|
9
10
|
):
|
|
11
|
+
def find(self, digest: str) -> Optional[DocumentProcess]:
|
|
12
|
+
item = self.get(key=digest)
|
|
13
|
+
if item:
|
|
14
|
+
return DocumentProcess.from_dict(item)
|
|
15
|
+
return None
|
|
10
16
|
|
|
11
17
|
def persist(self, instance: DocumentProcess) -> DocumentProcess:
|
|
12
18
|
self.put(instance.to_dict)
|
|
@@ -3,14 +3,14 @@ documente_shared/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
|
|
|
3
3
|
documente_shared/application/digest.py,sha256=Um6E8WfFri2_lly4RFWydJyvSfPZGFcOX-opEOzDCWc,172
|
|
4
4
|
documente_shared/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
documente_shared/domain/base_enum.py,sha256=DojAfn-zQdtjtImeHUpBzE6TBTm07XrbMOdW3h8RVd8,1449
|
|
6
|
-
documente_shared/domain/entities.py,sha256=
|
|
7
|
-
documente_shared/domain/enums.py,sha256=
|
|
8
|
-
documente_shared/domain/repositories.py,sha256=
|
|
6
|
+
documente_shared/domain/entities.py,sha256=YPYVVwn-vq8A1xiRC9kfERk3CE36cG7HTkRsbWri3TM,5188
|
|
7
|
+
documente_shared/domain/enums.py,sha256=wrMpM-1KgXFkd-He-3onNcqR3Zf53Q-_axjXGjx7MIY,435
|
|
8
|
+
documente_shared/domain/repositories.py,sha256=OJ6HKYx93RAHtj5M2uMk1P8cPdw7ubfhs1GMeUT_blU,540
|
|
9
9
|
documente_shared/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
documente_shared/infrastructure/dynamo_repositories.py,sha256=
|
|
10
|
+
documente_shared/infrastructure/dynamo_repositories.py,sha256=0bnDxw-fQglpXXg5E4p0wyIbLn4gUy6nbusosveXpyU,777
|
|
11
11
|
documente_shared/infrastructure/dynamo_table.py,sha256=5yF5EVQkHTZe4tLYZsfEDS8tp_iorMlMjNu-qn3Oj9E,2095
|
|
12
12
|
documente_shared/infrastructure/s3_bucket.py,sha256=s4VWcl0HK6uhjjZmKefOYW5A3Dx74R9KCuMmXQKUXnQ,1582
|
|
13
13
|
documente_shared/infrastructure/sqs_queue.py,sha256=PSiTAnjXvQ-W-9mzLpH2UjbQJTvYkMiaxNaMecF-cR4,1505
|
|
14
|
-
documente_shared-0.1.
|
|
15
|
-
documente_shared-0.1.
|
|
16
|
-
documente_shared-0.1.
|
|
14
|
+
documente_shared-0.1.17.dist-info/METADATA,sha256=keoPKGD0e_OrqM4avuizzPx_jZdxhfnXJ0lOucLSB6c,640
|
|
15
|
+
documente_shared-0.1.17.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
16
|
+
documente_shared-0.1.17.dist-info/RECORD,,
|
|
File without changes
|