documente_shared 0.1.115__py3-none-any.whl → 0.1.117__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.

@@ -2,7 +2,7 @@ import base64
2
2
  from typing import Optional
3
3
  from dataclasses import dataclass
4
4
 
5
- from documente_shared.application.files import get_filename_from_path, remove_extension
5
+ from documente_shared.application.files import get_filename_from_path, remove_extension, remove_slash_from_path
6
6
  from documente_shared.domain.exceptions import InMemoryDocumentContentError
7
7
 
8
8
 
@@ -39,7 +39,7 @@ class InMemoryDocument(object):
39
39
 
40
40
  @property
41
41
  def file_key(self) -> Optional[str]:
42
- return self.file_name
42
+ return remove_slash_from_path(self.file_path)
43
43
 
44
44
  @property
45
45
  def is_procesable(self) -> bool:
@@ -52,6 +52,12 @@ class InMemoryDocument(object):
52
52
  "file_base64": self.file_base64,
53
53
  }
54
54
 
55
+ @property
56
+ def to_queue_dict(self) -> dict:
57
+ return {
58
+ "file_path": self.file_path,
59
+ }
60
+
55
61
  @classmethod
56
62
  def from_dict(cls, data: dict):
57
63
  file_bytes = data.get("file_bytes")
@@ -27,50 +27,6 @@ class ProcessingCase(object):
27
27
  def __post_init__(self):
28
28
  self.items = self.items or []
29
29
 
30
- @property
31
- def strategy_id(self) ->str:
32
- return str(self.case_type)
33
-
34
- @property
35
- def is_procesable(self) -> bool:
36
- return self.items and len(self.items) > 0
37
-
38
- @property
39
- def is_bcp_microcredito(self) -> bool:
40
- return self.case_type and self.case_type.is_bcp_microcredito
41
-
42
- @property
43
- def is_univida_soat(self) -> bool:
44
- return self.case_type and self.case_type.is_univida_soat
45
-
46
- def pending(self, timezone: tzinfo = la_paz_tz):
47
- self.status = ProcessingStatus.PENDING
48
- self.started_at = None
49
-
50
- def enqueue(self, timezone: tzinfo = la_paz_tz):
51
- self.status = ProcessingStatus.ENQUEUED
52
- self.enqueued_at = datetime.now(tz=timezone)
53
-
54
- def processing(self, timezone: tzinfo = la_paz_tz):
55
- self.status = ProcessingStatus.PROCESSING
56
- self.started_at = datetime.now(tz=timezone)
57
-
58
- def failed(
59
- self,
60
- error_message: Optional[str] = None,
61
- timezone: tzinfo = la_paz_tz,
62
- ):
63
- self.status = ProcessingStatus.FAILED
64
- self.failed_at = datetime.now(tz=timezone)
65
-
66
- def completed(self, timezone: tzinfo = la_paz_tz):
67
- self.status = ProcessingStatus.COMPLETED
68
- self.completed_at = datetime.now(tz=timezone)
69
-
70
- def deleted(self):
71
- self.status = ProcessingStatus.DELETED
72
-
73
-
74
30
  def __eq__(self, other: 'ProcessingCase') -> bool:
75
31
  if not other:
76
32
  return False
@@ -88,6 +44,22 @@ class ProcessingCase(object):
88
44
  and self.metadata == other.metadata
89
45
  )
90
46
 
47
+ @property
48
+ def strategy_id(self) ->str:
49
+ return str(self.case_type)
50
+
51
+ @property
52
+ def is_procesable(self) -> bool:
53
+ return self.items and len(self.items) > 0
54
+
55
+ @property
56
+ def is_bcp_microcredito(self) -> bool:
57
+ return self.case_type and self.case_type.is_bcp_microcredito
58
+
59
+ @property
60
+ def is_univida_soat(self) -> bool:
61
+ return self.case_type and self.case_type.is_univida_soat
62
+
91
63
  @property
92
64
  def to_dict(self) -> dict:
93
65
  return {
@@ -130,6 +102,52 @@ class ProcessingCase(object):
130
102
  def has_procesable_items(self) -> bool:
131
103
  return len(self.procesable_items) > 0
132
104
 
105
+ def pending(self, timezone: tzinfo = la_paz_tz):
106
+ self.status = ProcessingStatus.PENDING
107
+ self.started_at = None
108
+
109
+ def enqueue(self, timezone: tzinfo = la_paz_tz):
110
+ self.status = ProcessingStatus.ENQUEUED
111
+ self.enqueued_at = datetime.now(tz=timezone)
112
+
113
+ def processing(self, timezone: tzinfo = la_paz_tz):
114
+ self.status = ProcessingStatus.PROCESSING
115
+ self.started_at = datetime.now(tz=timezone)
116
+
117
+ def failed(
118
+ self,
119
+ error_message: Optional[str] = None,
120
+ timezone: tzinfo = la_paz_tz,
121
+ ):
122
+ self.status = ProcessingStatus.FAILED
123
+ self.failed_at = datetime.now(tz=timezone)
124
+
125
+ def completed(self, timezone: tzinfo = la_paz_tz):
126
+ self.status = ProcessingStatus.COMPLETED
127
+ self.completed_at = datetime.now(tz=timezone)
128
+
129
+ def deleted(self):
130
+ self.status = ProcessingStatus.DELETED
131
+
132
+ def refresh_status(self):
133
+ if not self.items:
134
+ return
135
+
136
+ item_statuses = [item.status for item in self.items]
137
+
138
+ if any(status == ProcessingStatus.FAILED for status in item_statuses):
139
+ self.status = ProcessingStatus.INCOMPLETE
140
+ elif any(status == ProcessingStatus.PROCESSING for status in item_statuses):
141
+ self.status = ProcessingStatus.PROCESSING
142
+ elif all(status == ProcessingStatus.COMPLETED for status in item_statuses):
143
+ self.status = ProcessingStatus.COMPLETED
144
+ elif all(status == ProcessingStatus.PENDING for status in item_statuses):
145
+ self.status = ProcessingStatus.PENDING
146
+ else:
147
+ self.status = ProcessingStatus.PENDING
148
+
149
+
150
+
133
151
  @classmethod
134
152
  def from_dict(cls, data: dict) -> 'ProcessingCase':
135
153
  return cls(
@@ -161,3 +179,4 @@ class ProcessingCase(object):
161
179
  for item_dict in data.get('items', [])
162
180
  ]
163
181
  return instance
182
+
@@ -210,6 +210,27 @@ class ProcessingCaseItem(object):
210
210
  simple_dict = self.to_dict.copy()
211
211
  return simple_dict
212
212
 
213
+ @property
214
+ def to_queue_dict(self) -> dict:
215
+ queue_dict = self.to_dict.copy()
216
+ queue_dict["document"] = (
217
+ self.document.to_queue_dict
218
+ if self.document else None
219
+ )
220
+ queue_dict["processed_csv"] = (
221
+ self.processed_csv.to_queue_dict
222
+ if self.processed_csv else None
223
+ )
224
+ queue_dict["processed_xlsx"] = (
225
+ self.processed_xlsx.to_queue_dict
226
+ if self.processed_xlsx else None
227
+ )
228
+ queue_dict["processed_json"] = (
229
+ self.processed_json.to_queue_dict
230
+ if self.processed_json else None
231
+ )
232
+ return queue_dict
233
+
213
234
  @property
214
235
  def to_persist_dict(self) -> dict:
215
236
  simple_dict = self.to_dict.copy()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.115
3
+ Version: 0.1.117
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -16,10 +16,10 @@ documente_shared/domain/constants.py,sha256=NG5BGaXBr_FnzudjTRPxpDpyiSDdaB_PLCdl
16
16
  documente_shared/domain/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  documente_shared/domain/entities/document.py,sha256=9X6XCE-zTm0q8ASBn-5TAvNwK4iO_70KHkcgyMSO9JI,13044
18
18
  documente_shared/domain/entities/document_metadata.py,sha256=ygyFIC5qwxlm8DUM5kvVFny9zJfPQS8vNLM2br5XsQ8,2353
19
- documente_shared/domain/entities/in_memory_document.py,sha256=BswTG1LjrQ8nP3pb0T2bSODPjJ2ud4ifbnYxRdFlIhY,2116
20
- documente_shared/domain/entities/processing_case.py,sha256=NwGGGMyXnNprtO1lCP6rkPbhGhZ6C_z30OeHi_LHXDY,5706
19
+ documente_shared/domain/entities/in_memory_document.py,sha256=8JfVxbgqxkU3QvsuWzjpSp-end6JfffYDUSvMvrQsps,2284
20
+ documente_shared/domain/entities/processing_case.py,sha256=6_1J50jyb8XcOiXvGKDJxyLZ6we-RDOmdimalc3h7oM,6451
21
21
  documente_shared/domain/entities/processing_case_filters.py,sha256=harKyu7QEuL1bI_Z8_UxkVCMo5r9vHeNHyi_Ja07vjs,1953
22
- documente_shared/domain/entities/processing_case_item.py,sha256=KtH5JpJOcGLzVGQrcIGQY7CNWTwkm3_sriHM0ROF7SM,10255
22
+ documente_shared/domain/entities/processing_case_item.py,sha256=Kqozxf91C0SxOUl1ZbEU6_63Lz16mX4RfDqZ5Kf8mm4,10921
23
23
  documente_shared/domain/entities/processing_case_item_filters.py,sha256=R_AvDCB496Lww1qn2OwtltqULKE3IpcJB0ejnmRkg7Q,2009
24
24
  documente_shared/domain/entities/processing_documents.py,sha256=YYuTkdCNkqlO8cA0onJsZYtstxGt9M5NMuIO_87lB14,352
25
25
  documente_shared/domain/entities/processing_event.py,sha256=izdBXEz0TMNjxxZVjcM3YclzOv250JOV-amSpqmtQ9c,2180
@@ -55,6 +55,6 @@ documente_shared/infrastructure/services/http_scaling.py,sha256=cIo-61nfIwbtO86E
55
55
  documente_shared/infrastructure/sqs_queue.py,sha256=KZWeHZ9zmXmrxoNpOQX7GEdDhZ1knbPXgwSwFwJblGg,1504
56
56
  documente_shared/presentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
57
  documente_shared/presentation/presenters.py,sha256=GGAEwefmjCIVepsUA2oZOVLxXbhhiISPM0Jgt6dT6O0,423
58
- documente_shared-0.1.115.dist-info/METADATA,sha256=Jej_jT_-7b__6xiNpA4oiOdYUTPVmn-Z8haN3MIfxOI,963
59
- documente_shared-0.1.115.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
60
- documente_shared-0.1.115.dist-info/RECORD,,
58
+ documente_shared-0.1.117.dist-info/METADATA,sha256=58ttP8rKDPpwFiwi_qYPn3lu64ytZ0HWsz7v-wQyY2g,963
59
+ documente_shared-0.1.117.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
60
+ documente_shared-0.1.117.dist-info/RECORD,,