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

@@ -18,9 +18,9 @@ class HttpDocumentProcessingRepository(
18
18
  ):
19
19
  def find(self, digest: str) -> Optional[DocumentProcessing]:
20
20
  response = self.session.get(f"{self.api_url}/v1/documents/{digest}/")
21
- if response.status_code == 200:
22
- return self._build_document_processing(response)
23
- return None
21
+ if response.status_code not in [200, 201]:
22
+ return None
23
+ return self._build_document_processing(response)
24
24
 
25
25
  def persist(self, instance: DocumentProcessing) -> DocumentProcessing:
26
26
  logger.info(f"PERSISTING_DOCUMENT: data={instance.to_simple_dict}")
@@ -28,8 +28,7 @@ class HttpDocumentProcessingRepository(
28
28
  url=f"{self.api_url}/v1/documents/{instance.digest}/",
29
29
  json=instance.to_simple_dict,
30
30
  )
31
- if response.status_code in [200, 201]:
32
- logger.warning(f"PERSISTING_DOCUMENT ERROR: response={response.text}")
31
+ if response.status_code not in [200, 201]:
33
32
  raise Exception(f'Error persisting document processing: {response.text}')
34
33
  return self._build_document_processing(response)
35
34
 
@@ -38,13 +37,14 @@ class HttpDocumentProcessingRepository(
38
37
 
39
38
  def filter(self, statuses: List[DocumentProcessingStatus]) -> List[DocumentProcessing]:
40
39
  response = self.session.get(f"{self.api_url}/v1/documents/?statuses={statuses}")
41
- if response.status_code == 200:
42
- raw_response = response.json()
43
- return [
44
- DocumentProcessing.from_dict(camel_to_snake(item['documentProcessing']))
45
- for item in raw_response.get('data', [])
46
- ]
47
- return []
40
+ if response.status_code not in [200, 201]:
41
+ return []
42
+ raw_response = response.json()
43
+ return [
44
+ DocumentProcessing.from_dict(camel_to_snake(item['documentProcessing']))
45
+ for item in raw_response.get('data', [])
46
+ ]
47
+
48
48
 
49
49
  @classmethod
50
50
  def _build_document_processing(cls, response: Response) -> DocumentProcessing:
@@ -18,9 +18,9 @@ class HttpProcessingCaseRepository(
18
18
  ):
19
19
  def find(self, uuid: str, include_items: bool = False) -> Optional[ProcessingCase]:
20
20
  response = self.session.get(f"{self.api_url}/v1/processing-cases/{uuid}/")
21
- if response.status_code == 200:
22
- return self._build_processing_case(response)
23
- return None
21
+ if response.status_code not in [200, 201]:
22
+ return None
23
+ return self._build_processing_case(response)
24
24
 
25
25
  def persist(self, instance: ProcessingCase) -> ProcessingCase:
26
26
  logger.info(f"PERSISTING_PROCESSING_CASE: data={instance.to_dict}")
@@ -42,13 +42,13 @@ class HttpProcessingCaseRepository(
42
42
  "X-Tenant": filters.tenant_slug,
43
43
  }
44
44
  )
45
- if response.status_code == 200:
46
- raw_response = response.json()
47
- return [
48
- ProcessingCase.from_persist_dict(camel_to_snake(item_data))
49
- for item_data in raw_response.get('data', [])
50
- ]
51
- return []
45
+ if response.status_code not in [200, 201]:
46
+ return []
47
+ raw_response = response.json()
48
+ return [
49
+ ProcessingCase.from_persist_dict(camel_to_snake(item_data))
50
+ for item_data in raw_response.get('data', [])
51
+ ]
52
52
 
53
53
 
54
54
  @classmethod
@@ -18,15 +18,15 @@ class HttpProcessingCaseItemRepository(
18
18
  ):
19
19
  def find(self, uuid: str) -> Optional[ProcessingCaseItem]:
20
20
  response = self.session.get(f"{self.api_url}/v1/processing-case-items/{uuid}/")
21
- if response.status_code == 200:
22
- return self._build_processing_case_item(response)
23
- return None
21
+ if response.status_code not in [200, 201]:
22
+ return None
23
+ return self._build_processing_case_item(response)
24
24
 
25
25
  def find_by_digest(self, digest: str) -> Optional[ProcessingCaseItem]:
26
26
  response = self.session.get(f"{self.api_url}/v1/processing-case-items/{digest}/")
27
- if response.status_code == 200:
28
- return self._build_processing_case_item(response)
29
- return None
27
+ if response.status_code not in [200, 201]:
28
+ return None
29
+ return self._build_processing_case_item(response)
30
30
 
31
31
  def persist(self, instance: ProcessingCaseItem) -> ProcessingCaseItem:
32
32
  logger.info(f"PERSISTING_PROCESSING_CASE_ITEM: data={instance.to_simple_dict}")
@@ -34,10 +34,10 @@ class HttpProcessingCaseItemRepository(
34
34
  url=f"{self.api_url}/v1/processing-case-items/{instance.uuid}/",
35
35
  json=instance.to_persist_dict,
36
36
  )
37
- if response.status_code in [200, 201]:
38
- logger.warning(f"PERSISTING_PROCESSING_CASE_ITEM ERROR: response={response.text}")
39
- return self._build_processing_case_item(response)
40
- return instance
37
+ if response.status_code not in [200, 201]:
38
+ logger.info(f"PERSISTING_PROCESSING_CASE_ITEM ERROR: data={response.text}")
39
+ return instance
40
+ return self._build_processing_case_item(response)
41
41
 
42
42
  def remove(self, instance: ProcessingCaseItem):
43
43
  self.session.delete(f"{self.api_url}/v1/processing-case-items/{instance.uuid}/")
@@ -47,27 +47,27 @@ class HttpProcessingCaseItemRepository(
47
47
  filters: ProcessingCaseItemFilters,
48
48
  ) -> List[ProcessingCaseItem]:
49
49
  response = self.session.get(f"{self.api_url}/v1/processing-case-items/")
50
- if response.status_code == 200:
51
- raw_response = response.json()
52
- return [
53
- ProcessingCaseItem.from_dict(camel_to_snake(item_data))
54
- for item_data in raw_response.get('data', [])
55
- ]
56
- return []
57
-
50
+ if response.status_code not in [200, 201]:
51
+ return []
52
+ raw_response = response.json()
53
+ return [
54
+ ProcessingCaseItem.from_dict(camel_to_snake(item_data))
55
+ for item_data in raw_response.get('data', [])
56
+ ]
57
+
58
58
  def filter_with_tenant(
59
59
  self,
60
60
  tenant_slug: str,
61
61
  filters: ProcessingCaseItemFilters,
62
62
  ) -> List[ProcessingCaseItem]:
63
63
  response = self.session.get(f"{self.api_url}/v1/processing-case-items/")
64
- if response.status_code == 200:
65
- raw_response = response.json()
66
- return [
67
- ProcessingCaseItem.from_dict(camel_to_snake(item_data))
68
- for item_data in raw_response.get('data', [])
69
- ]
70
- return []
64
+ if response.status_code not in [200, 201]:
65
+ return []
66
+ raw_response = response.json()
67
+ return [
68
+ ProcessingCaseItem.from_dict(camel_to_snake(item_data))
69
+ for item_data in raw_response.get('data', [])
70
+ ]
71
71
 
72
72
  @classmethod
73
73
  def _build_processing_case_item(cls, response: Response) -> ProcessingCaseItem:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.110
3
+ Version: 0.1.111
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -43,9 +43,9 @@ documente_shared/infrastructure/repositories/__init__.py,sha256=47DEQpj8HBSa-_TI
43
43
  documente_shared/infrastructure/repositories/dynamo_document.py,sha256=_Yp4gtA-n-hJ2w2wAM5BMCs2Mf46Q2Kq3eHqlxudkL4,1443
44
44
  documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=jkTVHThKHshLI53OV7ivK-WchFoAZTnaXlgh_1OX52k,1446
45
45
  documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha256=B2ElsASpXNRkwwjdCqXyvDU-LBrLNdwPfHLMvvG9c-Y,1729
46
- documente_shared/infrastructure/repositories/http_document.py,sha256=xDFC4DcVC6FChtkuyKIc5-eRaJlVEXvfWsjslQ_PwaU,2361
47
- documente_shared/infrastructure/repositories/http_processing_case.py,sha256=zBHscJSlsqTLT-NrUT3spfLgS8ZB5Tv9IokCB2Iyvpo,2350
48
- documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=iKdk7qK7VKJcffrm0WAv3HKUBha1hjDl-ed9N_N4rFc,3180
46
+ documente_shared/infrastructure/repositories/http_document.py,sha256=TQdjKmly1m0L26_ksq9ce0_jv5NxtXvN8AT3Zd06yCE,2289
47
+ documente_shared/infrastructure/repositories/http_processing_case.py,sha256=a6JcICOCjce3WV-nXA2Fz7amU7wivBK-PkYwo6MGwa4,2356
48
+ documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=rztS_5oE2VDN9LOUATrjCuiKBkxmIwKAakp9AFo8Obc,3185
49
49
  documente_shared/infrastructure/repositories/mem_document.py,sha256=jg4rIjgSZijymjY9o7Q1lLcaiW9h-O8j6XljO1bJI7c,1299
50
50
  documente_shared/infrastructure/repositories/mem_processing_case.py,sha256=ZAQwp4j0DXQMt92Z-ZR4h9MtbUp9IYy0OHz_sHgkZxY,1147
51
51
  documente_shared/infrastructure/repositories/mem_processing_case_item.py,sha256=kQufzDTouu3agIXpEzRPdjltjTUFExrFbKkAZarGrUg,1419
@@ -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.110.dist-info/METADATA,sha256=o6kBqCT8Qq-8y5KJYsMJcYZ2nXFtFBDhUJJYuLvJzRY,963
59
- documente_shared-0.1.110.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
60
- documente_shared-0.1.110.dist-info/RECORD,,
58
+ documente_shared-0.1.111.dist-info/METADATA,sha256=WnELXs565Kcc2wY1MbiwCSLsO5Nbe9oZ1-BSIgQxzjo,963
59
+ documente_shared-0.1.111.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
60
+ documente_shared-0.1.111.dist-info/RECORD,,