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

@@ -1,10 +1,12 @@
1
- from dataclasses import dataclass
1
+ import base64
2
2
  from typing import Optional
3
+ from dataclasses import dataclass
3
4
 
4
5
  from documente_shared.application.files import (
5
6
  remove_slash_from_path,
6
7
  get_filename_from_path,
7
8
  )
9
+ from documente_shared.domain.exceptions import InMemoryDocumentContentError
8
10
 
9
11
 
10
12
  @dataclass
@@ -37,17 +39,25 @@ class InMemoryDocument(object):
37
39
 
38
40
  @property
39
41
  def to_dict(self) -> dict:
40
- data = dict()
41
- if self.file_path:
42
- data['file_path'] = remove_slash_from_path(self.file_path)
43
- if self.file_bytes:
44
- data['file_bytes'] = self.file_bytes.decode('utf-8')
45
- if self.file_base64:
46
- data['file_base64'] = self.file_base64
47
- return data
42
+ return {
43
+ "file_path": self.file_path,
44
+ "file_base64": self.file_base64,
45
+ }
48
46
 
49
47
  @classmethod
50
48
  def from_dict(cls, data: dict):
49
+ has_bytes_content = data.get('file_bytes') and isinstance(data['file_bytes'], bytes)
50
+ has_base64_content = data.get('file_base64') and isinstance(data['file_base64'], str)
51
+
52
+ if not has_bytes_content and not has_base64_content:
53
+ raise InMemoryDocumentContentError
54
+
55
+ if has_bytes_content and not data.get('file_base64'):
56
+ data['file_base64'] = base64.b64encode(data.get('file_bytes')).decode("utf-8")
57
+
58
+ if has_base64_content and not data.get('file_bytes'):
59
+ data['file_bytes'] = base64.b64decode(data.get('file_base64'))
60
+
51
61
  return cls(
52
62
  file_path=data.get('file_path'),
53
63
  file_bytes=data.get('file_bytes'),
@@ -88,9 +88,10 @@ class ProcessingCase(object):
88
88
  def to_dict(self) -> dict:
89
89
  return {
90
90
  'uuid': self.uuid,
91
- 'label': self.name,
91
+ 'tenant_slug': self.tenant_slug,
92
+ 'name': self.name,
92
93
  'status': str(self.status),
93
- 'category': (
94
+ 'case_type': (
94
95
  str(self.case_type)
95
96
  if self.case_type else None
96
97
  ),
@@ -5,7 +5,7 @@ from typing import Optional, List
5
5
 
6
6
  from documente_shared.application.time_utils import get_datetime_from_data
7
7
  from documente_shared.domain.constants import la_paz_tz
8
- from documente_shared.domain.entities.in_memory_result import InMemoryDocument
8
+ from documente_shared.domain.entities.in_memory_document import InMemoryDocument
9
9
  from documente_shared.domain.enums.common import ProcessingStatus, ProcessingSource
10
10
  from documente_shared.domain.enums.processing_case import ProcessingDocumentType
11
11
 
@@ -0,0 +1,5 @@
1
+
2
+
3
+
4
+ class InMemoryDocumentContentError(Exception):
5
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.97
3
+ Version: 0.1.99
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -14,10 +14,10 @@ documente_shared/domain/constants.py,sha256=NG5BGaXBr_FnzudjTRPxpDpyiSDdaB_PLCdl
14
14
  documente_shared/domain/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  documente_shared/domain/entities/document.py,sha256=xGZdrqqBkbvDbgoxUvIck6FplXjwLcZzFkcEsuh80u8,12819
16
16
  documente_shared/domain/entities/document_metadata.py,sha256=ygyFIC5qwxlm8DUM5kvVFny9zJfPQS8vNLM2br5XsQ8,2353
17
- documente_shared/domain/entities/in_memory_result.py,sha256=0sLNUrovKFQx4M-E9e4DrAiVgch2i4AKA-9BQBRaeI8,1482
18
- documente_shared/domain/entities/processing_case.py,sha256=ocPSvy0owiJq0cWnSHLIlY1UgE6Qz3ys0NwF6IxcMI0,5595
17
+ documente_shared/domain/entities/in_memory_document.py,sha256=kNszkMfWtmPQHRrARkAqMOUgre-oAPq-bcW-Z-GYoA8,1961
18
+ documente_shared/domain/entities/processing_case.py,sha256=2wD256_ra5szb8LVmGsauTsFTbkAqT1srOv5zuZQXgA,5640
19
19
  documente_shared/domain/entities/processing_case_filters.py,sha256=harKyu7QEuL1bI_Z8_UxkVCMo5r9vHeNHyi_Ja07vjs,1953
20
- documente_shared/domain/entities/processing_case_item.py,sha256=kYw0YmUjZvWv5SOOxqUlS5pf_Z9s3oCnEYFQl2swSAg,10106
20
+ documente_shared/domain/entities/processing_case_item.py,sha256=VbVOqAUHtcCHfAF5VpG47IWkM8t6eSX4VuDifJe7ZzA,10108
21
21
  documente_shared/domain/entities/processing_case_item_filters.py,sha256=R_AvDCB496Lww1qn2OwtltqULKE3IpcJB0ejnmRkg7Q,2009
22
22
  documente_shared/domain/entities/processing_event.py,sha256=izdBXEz0TMNjxxZVjcM3YclzOv250JOV-amSpqmtQ9c,2180
23
23
  documente_shared/domain/entities/scaling.py,sha256=Me1z3X-5NjzPMX-TBQ4xHwE_44tIJegi1QSCHQRNtx4,745
@@ -25,6 +25,7 @@ documente_shared/domain/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
25
25
  documente_shared/domain/enums/common.py,sha256=wJWYhh98sdCGL_1WodhYLpoT_IYTzkTDOexclpaIM-0,2827
26
26
  documente_shared/domain/enums/document.py,sha256=QwvckW-VJBSujllIVloKlZUh1pI5UnX4oueYbV5CYGw,3205
27
27
  documente_shared/domain/enums/processing_case.py,sha256=nIXtya6lmEOB0uWKkH4hLWOeBa8_BgKshHiMrGweswQ,1673
28
+ documente_shared/domain/exceptions.py,sha256=S2xkkFPiR8jVmA6UhRb-bPVrm6JvohXw2MUhZOzdnRo,58
28
29
  documente_shared/domain/interfaces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
30
  documente_shared/domain/interfaces/scaling.py,sha256=yWAud0rcLKMMf2-QxEE__GRpzqUY0H9_qxlQTfnRYmw,249
30
31
  documente_shared/domain/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -50,6 +51,6 @@ documente_shared/infrastructure/services/http_scaling.py,sha256=cIo-61nfIwbtO86E
50
51
  documente_shared/infrastructure/sqs_queue.py,sha256=KZWeHZ9zmXmrxoNpOQX7GEdDhZ1knbPXgwSwFwJblGg,1504
51
52
  documente_shared/presentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
53
  documente_shared/presentation/presenters.py,sha256=GGAEwefmjCIVepsUA2oZOVLxXbhhiISPM0Jgt6dT6O0,423
53
- documente_shared-0.1.97.dist-info/METADATA,sha256=bjl1H8EBDJcpKmzDZK77_hMeymmfZXmI0UagBzqG0Hc,920
54
- documente_shared-0.1.97.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
55
- documente_shared-0.1.97.dist-info/RECORD,,
54
+ documente_shared-0.1.99.dist-info/METADATA,sha256=09wpHFc5YW6xO2679vIMvj-UU-VWNjoewbz7YOcgYo4,920
55
+ documente_shared-0.1.99.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
56
+ documente_shared-0.1.99.dist-info/RECORD,,