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

@@ -20,3 +20,8 @@ def remove_slash_from_path(file_path: str) -> str:
20
20
  if file_path and file_path.startswith('/'):
21
21
  return file_path[1:]
22
22
  return file_path
23
+
24
+ def remove_extension(filename: str) -> str:
25
+ if filename and '.' in filename:
26
+ return filename.rsplit('.', 1)[0]
27
+ return filename
@@ -4,7 +4,7 @@ from datetime import datetime, tzinfo
4
4
  from decimal import Decimal
5
5
  from typing import Optional, List
6
6
 
7
- from documente_shared.application.files import remove_slash_from_path, get_filename_from_path
7
+ from documente_shared.application.files import remove_slash_from_path, get_filename_from_path, remove_extension
8
8
  from documente_shared.application.numbers import normalize_number
9
9
  from documente_shared.application.time_utils import get_datetime_from_data
10
10
  from documente_shared.domain.constants import la_paz_tz
@@ -140,6 +140,10 @@ class DocumentProcessing(object):
140
140
  def extended_filename(self) -> str:
141
141
  return self.file_path.split('/')[-1]
142
142
 
143
+ @property
144
+ def raw_file_name(self) -> str:
145
+ return remove_extension(self.extended_filename)
146
+
143
147
  @property
144
148
  def filename(self) -> str:
145
149
  filename_with_extension = self.extended_filename
@@ -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
5
+ from documente_shared.application.files import get_filename_from_path, remove_extension
6
6
  from documente_shared.domain.exceptions import InMemoryDocumentContentError
7
7
 
8
8
 
@@ -33,6 +33,10 @@ class InMemoryDocument(object):
33
33
  def file_name(self) -> Optional[str]:
34
34
  return get_filename_from_path(self.file_path) if self.file_path else None
35
35
 
36
+ @property
37
+ def raw_file_name(self) -> str:
38
+ return remove_extension(self.file_name)
39
+
36
40
  @property
37
41
  def file_key(self) -> Optional[str]:
38
42
  return self.file_name
@@ -36,34 +36,25 @@ class ProcessingCaseItem(object):
36
36
  self.feedback = self.feedback or []
37
37
  self.metadata = self.metadata or {}
38
38
 
39
- @property
40
- def has_processed_csv(self) -> bool:
41
- return self.processed_csv and self.processed_csv.is_valid
42
39
 
43
- @property
44
- def has_processed_xlsx(self) -> bool:
45
- return self.processed_xlsx and self.processed_xlsx.is_valid
40
+ def __eq__(self, other: 'ProcessingCaseItem') -> bool:
41
+ if not other:
42
+ return False
46
43
 
47
- @property
48
- def has_processed_json(self) -> bool:
49
- return self.processed_json and self.processed_json.is_valid
50
-
51
- @property
52
- def is_procesable(self) -> bool:
53
44
  return (
54
- (self.status.is_pending or self.status.is_enqueued)
55
- and self.digest
56
- and self.document
57
- and self.document.is_procesable
45
+ self.uuid == other.uuid
46
+ and self.digest == other.digest
47
+ and self.status == other.status
48
+ and self.document_type == other.document_type
49
+ and self.document == other.document
50
+ and self.processing_time == other.processing_time
51
+ and self.processing_confidence == other.processing_confidence
52
+ and self.uploaded_at == other.uploaded_at
53
+ and self.started_at == other.started_at
54
+ and self.failed_at == other.failed_at
55
+ and self.completed_at == other.completed_at
58
56
  )
59
57
 
60
- @property
61
- def is_finished(self) -> bool:
62
- return self.status in [
63
- ProcessingStatus.COMPLETED,
64
- ProcessingStatus.FAILED,
65
- ]
66
-
67
58
  def pending(self, timezone: tzinfo = la_paz_tz):
68
59
  self.status = ProcessingStatus.PENDING
69
60
  self.started_at = None
@@ -73,9 +64,9 @@ class ProcessingCaseItem(object):
73
64
  self.started_at = datetime.now(tz=timezone)
74
65
 
75
66
  def failed(
76
- self,
77
- error_message: Optional[str] = None,
78
- timezone: tzinfo = la_paz_tz,
67
+ self,
68
+ error_message: Optional[str] = None,
69
+ timezone: tzinfo = la_paz_tz,
79
70
  ):
80
71
  self.status = ProcessingStatus.FAILED
81
72
  self.failed_at = datetime.now(tz=timezone)
@@ -90,28 +81,71 @@ class ProcessingCaseItem(object):
90
81
 
91
82
  def deleted(self):
92
83
  self.status = ProcessingStatus.DELETED
93
-
84
+
94
85
  def in_review(self):
95
86
  self.status = ProcessingStatus.IN_REVIEW
96
87
 
97
- def __eq__(self, other: 'ProcessingCaseItem') -> bool:
98
- if not other:
99
- return False
88
+ def overload(
89
+ self,
90
+ new_instance: 'ProcessingCaseItem',
91
+ properties: List[str] = None,
92
+ ):
93
+ instance_properties = properties or [
94
+ 'status',
95
+ 'document',
96
+ 'document_type',
97
+ 'uploaded_from',
98
+ 'processed_csv',
99
+ 'processed_xlsx',
100
+ 'processed_json',
101
+ 'processing_time',
102
+ 'processing_confidence',
103
+ 'uploaded_at',
104
+ 'started_at',
105
+ 'failed_at',
106
+ 'completed_at',
107
+ 'feedback',
108
+ 'metadata',
109
+ ]
110
+ for _property in instance_properties:
111
+ property_value = getattr(new_instance, _property)
112
+ if not hasattr(self, _property):
113
+ continue
114
+ setattr(self, _property, property_value)
115
+ return self
116
+
117
+ @property
118
+ def combined_id(self) -> str:
119
+ return f"{self.case_id}_{self.uuid}"
120
+
121
+ @property
122
+ def has_processed_csv(self) -> bool:
123
+ return self.processed_csv and self.processed_csv.is_valid
124
+
125
+ @property
126
+ def has_processed_xlsx(self) -> bool:
127
+ return self.processed_xlsx and self.processed_xlsx.is_valid
100
128
 
129
+ @property
130
+ def has_processed_json(self) -> bool:
131
+ return self.processed_json and self.processed_json.is_valid
132
+
133
+ @property
134
+ def is_procesable(self) -> bool:
101
135
  return (
102
- self.uuid == other.uuid
103
- and self.digest == other.digest
104
- and self.status == other.status
105
- and self.document_type == other.document_type
106
- and self.document == other.document
107
- and self.processing_time == other.processing_time
108
- and self.processing_confidence == other.processing_confidence
109
- and self.uploaded_at == other.uploaded_at
110
- and self.started_at == other.started_at
111
- and self.failed_at == other.failed_at
112
- and self.completed_at == other.completed_at
136
+ (self.status.is_pending or self.status.is_enqueued)
137
+ and self.digest
138
+ and self.document
139
+ and self.document.is_procesable
113
140
  )
114
141
 
142
+ @property
143
+ def is_finished(self) -> bool:
144
+ return self.status in [
145
+ ProcessingStatus.COMPLETED,
146
+ ProcessingStatus.FAILED,
147
+ ]
148
+
115
149
  @property
116
150
  def to_dict(self) -> dict:
117
151
  return {
@@ -185,35 +219,6 @@ class ProcessingCaseItem(object):
185
219
  simple_dict["processed_json_path"] = self.processed_json.file_path if self.processed_json else None
186
220
  return simple_dict
187
221
 
188
- def overload(
189
- self,
190
- new_instance: 'ProcessingCaseItem',
191
- properties: List[str] = None,
192
- ):
193
- instance_properties = properties or [
194
- 'status',
195
- 'document',
196
- 'document_type',
197
- 'uploaded_from',
198
- 'processed_csv',
199
- 'processed_xlsx',
200
- 'processed_json',
201
- 'processing_time',
202
- 'processing_confidence',
203
- 'uploaded_at',
204
- 'started_at',
205
- 'failed_at',
206
- 'completed_at',
207
- 'feedback',
208
- 'metadata',
209
- ]
210
- for _property in instance_properties:
211
- property_value = getattr(new_instance, _property)
212
- if not hasattr(self, _property):
213
- continue
214
- setattr(self, _property, property_value)
215
- return self
216
-
217
222
  @classmethod
218
223
  def from_dict(cls, data: dict) -> 'ProcessingCaseItem':
219
224
  return cls(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.105
3
+ Version: 0.1.107
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -3,7 +3,7 @@ documente_shared/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
3
3
  documente_shared/application/dates.py,sha256=uExNddWmX9VEX_u420JGoC7fL-ieJ4956I0aw_WX3sQ,109
4
4
  documente_shared/application/digest.py,sha256=Um6E8WfFri2_lly4RFWydJyvSfPZGFcOX-opEOzDCWc,172
5
5
  documente_shared/application/exceptions.py,sha256=lQM8m7wmI9OTLGva0gd7s7YT7ldaTk_Ln4t32PpzNf8,654
6
- documente_shared/application/files.py,sha256=ADiWi6Mk3YQGx3boGsDqdb5wk8qmabkGRy7bhNFa1OY,649
6
+ documente_shared/application/files.py,sha256=_qkpeFPVmHyNhD6_PFZdzhyYvshJVeeSiwuTggK-A9Q,793
7
7
  documente_shared/application/json.py,sha256=5y67-DoiJlq_fLefgJ8YBVsdyua4KykxbSUKQqcwnnQ,1223
8
8
  documente_shared/application/numbers.py,sha256=rik1SqMxLzXNL2S5Yh1Q8CSONdcjjoCBnByFasxR4_Q,212
9
9
  documente_shared/application/payloads.py,sha256=s6SjaNN18_aQ6IL083Zq2J8thRCZ_zC2sn7hkfjK_Go,453
@@ -14,12 +14,12 @@ documente_shared/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
14
14
  documente_shared/domain/base_enum.py,sha256=DojAfn-zQdtjtImeHUpBzE6TBTm07XrbMOdW3h8RVd8,1449
15
15
  documente_shared/domain/constants.py,sha256=NG5BGaXBr_FnzudjTRPxpDpyiSDdaB_PLCdlYlFUQeU,187
16
16
  documente_shared/domain/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- documente_shared/domain/entities/document.py,sha256=v0ZM3qmdk6zuGt7UqMseD1aN3RA8KjTtsGZuJq1dDGI,12919
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=5MFG5V4EtNr-wwrLEFZusZPWvla52g5wuI6es5nQ4tM,1999
19
+ documente_shared/domain/entities/in_memory_document.py,sha256=BswTG1LjrQ8nP3pb0T2bSODPjJ2ud4ifbnYxRdFlIhY,2116
20
20
  documente_shared/domain/entities/processing_case.py,sha256=NwGGGMyXnNprtO1lCP6rkPbhGhZ6C_z30OeHi_LHXDY,5706
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=xmeN99qiGfVptIAs6t2DOksAJhkfnhzOaP9p5yiPR1s,10146
22
+ documente_shared/domain/entities/processing_case_item.py,sha256=LiGtWVw5Di1s87I8ZvY1K8ZcBke06jCV1u7rSh06G7w,10249
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.105.dist-info/METADATA,sha256=OcevFbclqyMWrlddbpe3VYcHa8pzTF46VxIBmu9Rqcg,963
59
- documente_shared-0.1.105.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
60
- documente_shared-0.1.105.dist-info/RECORD,,
58
+ documente_shared-0.1.107.dist-info/METADATA,sha256=KKuWwC9UvgY_oyO456dwbS7XZZfLuJJfIZSC5PSPFms,963
59
+ documente_shared-0.1.107.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
60
+ documente_shared-0.1.107.dist-info/RECORD,,