documente_shared 0.1.47__tar.gz → 0.1.50__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.47 → documente_shared-0.1.50}/PKG-INFO +1 -1
- documente_shared-0.1.47/documente_shared/domain/entities/document_process.py → documente_shared-0.1.50/documente_shared/domain/entities/document.py +29 -28
- documente_shared-0.1.47/documente_shared/domain/entities/document_process_metadata.py → documente_shared-0.1.50/documente_shared/domain/entities/document_metadata.py +1 -1
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/domain/enums.py +6 -6
- documente_shared-0.1.50/documente_shared/domain/repositories.py +25 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/infrastructure/dynamo_repositories.py +11 -11
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/infrastructure/s3_bucket.py +1 -1
- {documente_shared-0.1.47 → documente_shared-0.1.50}/pyproject.toml +1 -1
- documente_shared-0.1.47/documente_shared/domain/repositories.py +0 -25
- {documente_shared-0.1.47 → documente_shared-0.1.50}/README.md +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/__init__.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/application/__init__.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/application/digest.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/application/exceptions.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/application/time_utils.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/application/timezone.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/domain/__init__.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/domain/base_enum.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/domain/entities/__init__.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/infrastructure/__init__.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/infrastructure/dynamo_table.py +0 -0
- {documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/infrastructure/sqs_queue.py +0 -0
|
@@ -4,11 +4,11 @@ from decimal import Decimal
|
|
|
4
4
|
from typing import Optional, List
|
|
5
5
|
|
|
6
6
|
from documente_shared.application.time_utils import get_datetime_from_data
|
|
7
|
-
from documente_shared.domain.entities.
|
|
7
|
+
from documente_shared.domain.entities.document_metadata import DocumentProcessingMetadata
|
|
8
8
|
from documente_shared.domain.enums import (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
DocumentProcessingStatus,
|
|
10
|
+
DocumentProcessingSubCategory,
|
|
11
|
+
DocumentProcessingCategory,
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
def remove_slash_from_path(path: str) -> str:
|
|
@@ -17,13 +17,13 @@ def remove_slash_from_path(path: str) -> str:
|
|
|
17
17
|
return path
|
|
18
18
|
|
|
19
19
|
@dataclass
|
|
20
|
-
class
|
|
20
|
+
class DocumentProcessing(object):
|
|
21
21
|
digest: str
|
|
22
|
-
status:
|
|
22
|
+
status: DocumentProcessingStatus
|
|
23
23
|
file_path: Optional[str] = None
|
|
24
24
|
file_bytes: Optional[bytes] = None
|
|
25
|
-
category: Optional[
|
|
26
|
-
sub_category: Optional[
|
|
25
|
+
category: Optional[DocumentProcessingCategory] = None
|
|
26
|
+
sub_category: Optional[DocumentProcessingSubCategory] = None
|
|
27
27
|
processed_csv_path: Optional[str] = None
|
|
28
28
|
processed_csv_bytes: Optional[bytes] = None
|
|
29
29
|
processed_xlsx_path: Optional[str] = None
|
|
@@ -39,30 +39,30 @@ class DocumentProcess(object):
|
|
|
39
39
|
failed_at: Optional[datetime] = None
|
|
40
40
|
failed_reason: Optional[str] = None
|
|
41
41
|
completed_at: Optional[datetime] = None
|
|
42
|
-
metadata_items: Optional[List[
|
|
42
|
+
metadata_items: Optional[List[DocumentProcessingMetadata]] = None
|
|
43
43
|
|
|
44
44
|
def __post_init__(self):
|
|
45
45
|
self.metadata_items = self.metadata_items or []
|
|
46
46
|
|
|
47
47
|
@property
|
|
48
48
|
def is_pending(self) -> bool:
|
|
49
|
-
return self.status ==
|
|
49
|
+
return self.status == DocumentProcessingStatus.PENDING
|
|
50
50
|
|
|
51
51
|
@property
|
|
52
52
|
def is_enqueued(self) -> bool:
|
|
53
|
-
return self.status ==
|
|
53
|
+
return self.status == DocumentProcessingStatus.ENQUEUED
|
|
54
54
|
|
|
55
55
|
@property
|
|
56
56
|
def is_processing(self) -> bool:
|
|
57
|
-
return self.status ==
|
|
57
|
+
return self.status == DocumentProcessingStatus.PROCESSING
|
|
58
58
|
|
|
59
59
|
@property
|
|
60
60
|
def is_completed(self) -> bool:
|
|
61
|
-
return self.status ==
|
|
61
|
+
return self.status == DocumentProcessingStatus.COMPLETED
|
|
62
62
|
|
|
63
63
|
@property
|
|
64
64
|
def is_failed(self) -> bool:
|
|
65
|
-
return self.status ==
|
|
65
|
+
return self.status == DocumentProcessingStatus.FAILED
|
|
66
66
|
|
|
67
67
|
@property
|
|
68
68
|
def is_valid(self) -> bool:
|
|
@@ -75,29 +75,29 @@ class DocumentProcess(object):
|
|
|
75
75
|
@property
|
|
76
76
|
def is_finished(self) -> bool:
|
|
77
77
|
return self.status in [
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
DocumentProcessingStatus.COMPLETED,
|
|
79
|
+
DocumentProcessingStatus.FAILED,
|
|
80
80
|
]
|
|
81
81
|
|
|
82
82
|
def enqueue(self):
|
|
83
|
-
self.status =
|
|
83
|
+
self.status = DocumentProcessingStatus.ENQUEUED
|
|
84
84
|
self.enqueued_at = datetime.now()
|
|
85
85
|
|
|
86
86
|
def processing(self):
|
|
87
|
-
self.status =
|
|
87
|
+
self.status = DocumentProcessingStatus.PROCESSING
|
|
88
88
|
self.started_at = datetime.now()
|
|
89
89
|
|
|
90
90
|
def failed(self, error_message: Optional[str] = None):
|
|
91
91
|
self.failed_reason = error_message
|
|
92
|
-
self.status =
|
|
92
|
+
self.status = DocumentProcessingStatus.FAILED
|
|
93
93
|
self.failed_at = datetime.now()
|
|
94
94
|
|
|
95
95
|
def completed(self):
|
|
96
|
-
self.status =
|
|
96
|
+
self.status = DocumentProcessingStatus.COMPLETED
|
|
97
97
|
self.completed_at = datetime.now()
|
|
98
98
|
|
|
99
99
|
def deleted(self):
|
|
100
|
-
self.status =
|
|
100
|
+
self.status = DocumentProcessingStatus.DELETED
|
|
101
101
|
|
|
102
102
|
@property
|
|
103
103
|
def file_key(self) -> str:
|
|
@@ -128,7 +128,7 @@ class DocumentProcess(object):
|
|
|
128
128
|
filename_with_extension = self.extended_filename
|
|
129
129
|
return filename_with_extension.split('.')[0]
|
|
130
130
|
|
|
131
|
-
def __eq__(self, other: '
|
|
131
|
+
def __eq__(self, other: 'DocumentProcessing') -> bool:
|
|
132
132
|
if not other:
|
|
133
133
|
return False
|
|
134
134
|
|
|
@@ -185,7 +185,7 @@ class DocumentProcess(object):
|
|
|
185
185
|
|
|
186
186
|
def overload(
|
|
187
187
|
self,
|
|
188
|
-
new_instance: '
|
|
188
|
+
new_instance: 'DocumentProcessing',
|
|
189
189
|
properties: List[str] = None,
|
|
190
190
|
):
|
|
191
191
|
instance_properties = properties or [
|
|
@@ -202,6 +202,7 @@ class DocumentProcess(object):
|
|
|
202
202
|
'processed_json_path',
|
|
203
203
|
'processed_json_bytes',
|
|
204
204
|
'processed_metadata_path',
|
|
205
|
+
'processed_metadata_bytes',
|
|
205
206
|
'processing_time',
|
|
206
207
|
'issued_at',
|
|
207
208
|
'uploaded_at',
|
|
@@ -219,17 +220,17 @@ class DocumentProcess(object):
|
|
|
219
220
|
return self
|
|
220
221
|
|
|
221
222
|
@classmethod
|
|
222
|
-
def from_dict(cls, data: dict) -> '
|
|
223
|
+
def from_dict(cls, data: dict) -> 'DocumentProcessing':
|
|
223
224
|
return cls(
|
|
224
225
|
digest=data.get('digest'),
|
|
225
|
-
status=
|
|
226
|
+
status=DocumentProcessingStatus.from_value(data.get('status')),
|
|
226
227
|
file_path=data.get('file_path'),
|
|
227
228
|
category=(
|
|
228
|
-
|
|
229
|
+
DocumentProcessingCategory.from_value(data.get('category'))
|
|
229
230
|
if data.get('category') else None
|
|
230
231
|
),
|
|
231
232
|
sub_category=(
|
|
232
|
-
|
|
233
|
+
DocumentProcessingSubCategory.from_value(data.get('sub_category'))
|
|
233
234
|
if data.get('sub_category') else None
|
|
234
235
|
),
|
|
235
236
|
processed_csv_path=data.get('processed_csv_path'),
|
|
@@ -248,7 +249,7 @@ class DocumentProcess(object):
|
|
|
248
249
|
failed_reason=data.get('failed_reason'),
|
|
249
250
|
completed_at=get_datetime_from_data(input_datetime=data.get('completed_at')),
|
|
250
251
|
metadata_items=[
|
|
251
|
-
|
|
252
|
+
DocumentProcessingMetadata.from_dict(metadata)
|
|
252
253
|
for metadata in data.get('metadata_items', [])
|
|
253
254
|
],
|
|
254
255
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from documente_shared.domain.base_enum import BaseEnum
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
class
|
|
4
|
+
class DocumentProcessingStatus(BaseEnum):
|
|
5
5
|
PENDING = 'PENDING'
|
|
6
6
|
ENQUEUED = 'ENQUEUED'
|
|
7
7
|
PROCESSING = 'PROCESSING'
|
|
@@ -11,20 +11,20 @@ class DocumentProcessStatus(BaseEnum):
|
|
|
11
11
|
CANCELLED = 'CANCELLED'
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
class
|
|
14
|
+
class DocumentProcessingCategory(BaseEnum):
|
|
15
15
|
CIRCULAR = 'CIRCULAR'
|
|
16
16
|
DESGRAVAMEN = 'DESGRAVAMEN'
|
|
17
17
|
|
|
18
18
|
@property
|
|
19
19
|
def is_circular(self):
|
|
20
|
-
return self ==
|
|
20
|
+
return self == DocumentProcessingCategory.CIRCULAR
|
|
21
21
|
|
|
22
22
|
@property
|
|
23
23
|
def is_desgravamen(self):
|
|
24
|
-
return self ==
|
|
24
|
+
return self == DocumentProcessingCategory.DESGRAVAMEN
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
class
|
|
27
|
+
class DocumentProcessingSubCategory(BaseEnum):
|
|
28
28
|
# Circulares
|
|
29
29
|
CC_COMBINADA = 'CC_COMBINADA'
|
|
30
30
|
CC_NORMATIVA = 'CC_NORMATIVA'
|
|
@@ -32,5 +32,5 @@ class DocumentProcessSubCategory(BaseEnum):
|
|
|
32
32
|
CC_RETENCION_SUSPENSION_REMISION = 'CC_RETENCION_SUSPENSION_REMISION'
|
|
33
33
|
|
|
34
34
|
# Desgravamenes
|
|
35
|
-
|
|
35
|
+
DS_CREDISEGURO = 'DS_CREDISEGURO'
|
|
36
36
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Optional, List
|
|
3
|
+
|
|
4
|
+
from documente_shared.domain.entities.document import DocumentProcessing
|
|
5
|
+
from documente_shared.domain.enums import DocumentProcessingStatus
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DocumentProcessingRepository(ABC):
|
|
9
|
+
|
|
10
|
+
@abstractmethod
|
|
11
|
+
def find(self, digest: str) ->Optional[DocumentProcessing]:
|
|
12
|
+
raise NotImplementedError
|
|
13
|
+
|
|
14
|
+
@abstractmethod
|
|
15
|
+
def persist(self, instance: DocumentProcessing) -> DocumentProcessing:
|
|
16
|
+
raise NotImplementedError
|
|
17
|
+
|
|
18
|
+
@abstractmethod
|
|
19
|
+
def remove(self, instance: DocumentProcessing):
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def filter(self, statuses: List[DocumentProcessingStatus]) -> List[DocumentProcessing]:
|
|
25
|
+
raise NotImplementedError
|
|
@@ -2,31 +2,31 @@ from typing import Optional, List
|
|
|
2
2
|
|
|
3
3
|
from boto3.dynamodb.conditions import Key
|
|
4
4
|
|
|
5
|
-
from documente_shared.domain.entities.
|
|
6
|
-
from documente_shared.domain.enums import
|
|
7
|
-
from documente_shared.domain.repositories import
|
|
5
|
+
from documente_shared.domain.entities.document import DocumentProcessing
|
|
6
|
+
from documente_shared.domain.enums import DocumentProcessingStatus, DocumentProcessingCategory
|
|
7
|
+
from documente_shared.domain.repositories import DocumentProcessingRepository
|
|
8
8
|
from documente_shared.infrastructure.dynamo_table import DynamoDBTable
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class DynamoDocumentProcessingRepository(
|
|
13
13
|
DynamoDBTable,
|
|
14
|
-
|
|
14
|
+
DocumentProcessingRepository,
|
|
15
15
|
):
|
|
16
|
-
def find(self, digest: str) -> Optional[
|
|
16
|
+
def find(self, digest: str) -> Optional[DocumentProcessing]:
|
|
17
17
|
item = self.get(key={'digest': digest})
|
|
18
18
|
if item:
|
|
19
|
-
return
|
|
19
|
+
return DocumentProcessing.from_dict(item)
|
|
20
20
|
return None
|
|
21
21
|
|
|
22
|
-
def persist(self, instance:
|
|
22
|
+
def persist(self, instance: DocumentProcessing) -> DocumentProcessing:
|
|
23
23
|
self.put(instance.to_simple_dict)
|
|
24
24
|
return instance
|
|
25
25
|
|
|
26
|
-
def remove(self, instance:
|
|
26
|
+
def remove(self, instance: DocumentProcessing):
|
|
27
27
|
self.delete(key={'digest': instance.digest})
|
|
28
28
|
|
|
29
|
-
def filter(self, statuses: List[
|
|
29
|
+
def filter(self, statuses: List[DocumentProcessingStatus]) -> List[DocumentProcessing]:
|
|
30
30
|
items = []
|
|
31
31
|
|
|
32
32
|
for status in statuses:
|
|
@@ -38,6 +38,6 @@ class DynamoDocumentProcessRepository(
|
|
|
38
38
|
items.extend(status_items)
|
|
39
39
|
|
|
40
40
|
return [
|
|
41
|
-
|
|
41
|
+
DocumentProcessing.from_dict(item)
|
|
42
42
|
for item in items
|
|
43
43
|
]
|
{documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/infrastructure/s3_bucket.py
RENAMED
|
@@ -3,7 +3,7 @@ import boto3
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
from typing import Optional
|
|
5
5
|
|
|
6
|
-
from documente_shared.domain.entities.
|
|
6
|
+
from documente_shared.domain.entities.document import remove_slash_from_path
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def remove_none_values(data: dict) -> dict: # noqa: WPS110
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
from typing import Optional, List
|
|
3
|
-
|
|
4
|
-
from documente_shared.domain.entities.document_process import DocumentProcess
|
|
5
|
-
from documente_shared.domain.enums import DocumentProcessStatus
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class DocumentProcessRepository(ABC):
|
|
9
|
-
|
|
10
|
-
@abstractmethod
|
|
11
|
-
def find(self, digest: str) ->Optional[DocumentProcess]:
|
|
12
|
-
raise NotImplementedError
|
|
13
|
-
|
|
14
|
-
@abstractmethod
|
|
15
|
-
def persist(self, instance: DocumentProcess) -> DocumentProcess:
|
|
16
|
-
raise NotImplementedError
|
|
17
|
-
|
|
18
|
-
@abstractmethod
|
|
19
|
-
def remove(self, instance: DocumentProcess):
|
|
20
|
-
raise NotImplementedError
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
@abstractmethod
|
|
24
|
-
def filter(self, statuses: List[DocumentProcessStatus]) -> List[DocumentProcess]:
|
|
25
|
-
raise NotImplementedError
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/application/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/application/exceptions.py
RENAMED
|
File without changes
|
{documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/application/time_utils.py
RENAMED
|
File without changes
|
{documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/application/timezone.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/domain/entities/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/infrastructure/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/infrastructure/dynamo_table.py
RENAMED
|
File without changes
|
{documente_shared-0.1.47 → documente_shared-0.1.50}/documente_shared/infrastructure/sqs_queue.py
RENAMED
|
File without changes
|