nucliadb-utils 6.3.1.post3577__py3-none-any.whl → 6.3.1.post3590__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.
@@ -141,7 +141,10 @@ class AzureStorageField(StorageField):
141
141
  bucket = self.bucket
142
142
  else:
143
143
  return None
144
- return await self.storage.object_store.get_metadata(bucket, key)
144
+ try:
145
+ return await self.storage.object_store.get_metadata(bucket, key)
146
+ except ObjectNotFoundError:
147
+ return None
145
148
 
146
149
  async def upload(self, iterator: AsyncIterator, origin: CloudFile) -> CloudFile:
147
150
  self.field = await self.start(origin)
@@ -308,3 +308,11 @@ class LocalStorage(Storage):
308
308
  os.makedirs(os.path.dirname(path), exist_ok=True)
309
309
  with open(path, "wb") as file:
310
310
  file.write(data)
311
+ metadata_path = f"{path}.metadata"
312
+ metadata = ObjectMetadata(
313
+ filename=key.split("/")[-1],
314
+ content_type="application/octet-stream",
315
+ size=len(data),
316
+ )
317
+ with open(metadata_path, "w") as file:
318
+ file.write(json.dumps(metadata.model_dump()))
@@ -332,6 +332,10 @@ class Storage(abc.ABC, metaclass=abc.ABCMeta):
332
332
  key = KB_RESOURCE_FIELD.format(kbid=kbid, uuid=uuid, field=field)
333
333
  return self.field_klass(storage=self, bucket=bucket, fullkey=key, field=old_field)
334
334
 
335
+ async def exists_object(self, bucket: str, key: str) -> bool:
336
+ sf: StorageField = self.field_klass(storage=self, bucket=bucket, fullkey=key)
337
+ return await sf.exists() is not None
338
+
335
339
  def file_extracted(
336
340
  self, kbid: str, uuid: str, field_type: str, field: str, key: str
337
341
  ) -> StorageField:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nucliadb_utils
3
- Version: 6.3.1.post3577
3
+ Version: 6.3.1.post3590
4
4
  Summary: NucliaDB util library
5
5
  Author-email: Nuclia <nucliadb@nuclia.com>
6
6
  License: AGPL
@@ -27,8 +27,8 @@ Requires-Dist: nats-py[nkeys]>=2.6.0
27
27
  Requires-Dist: PyNaCl
28
28
  Requires-Dist: pyjwt>=2.4.0
29
29
  Requires-Dist: mrflagly>=0.2.9
30
- Requires-Dist: nucliadb-protos>=6.3.1.post3577
31
- Requires-Dist: nucliadb-telemetry>=6.3.1.post3577
30
+ Requires-Dist: nucliadb-protos>=6.3.1.post3590
31
+ Requires-Dist: nucliadb-telemetry>=6.3.1.post3590
32
32
  Provides-Extra: cache
33
33
  Requires-Dist: redis>=4.3.4; extra == "cache"
34
34
  Requires-Dist: orjson>=3.6.7; extra == "cache"
@@ -39,15 +39,15 @@ nucliadb_utils/nuclia_usage/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn
39
39
  nucliadb_utils/nuclia_usage/utils/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
40
40
  nucliadb_utils/nuclia_usage/utils/kb_usage_report.py,sha256=6lLuxCCPQVn3dOuZNL5ThPjl2yws-1TJ_7duhQSWkPU,3934
41
41
  nucliadb_utils/storages/__init__.py,sha256=5Qc8AUWiJv9_JbGCBpAn88AIJhwDlm0OPQpg2ZdRL4U,872
42
- nucliadb_utils/storages/azure.py,sha256=b5WzTjwsyrFxkuD5GzOUSBw6Szm0OkNt8t2NGoMiTJI,16557
42
+ nucliadb_utils/storages/azure.py,sha256=_BAQiDIey86vawN5eyo3_RwHkSELwerM7lUVyRT52q8,16634
43
43
  nucliadb_utils/storages/exceptions.py,sha256=GOPKH-F3dPTfHEkwGNfVkSfF70eWJJXjI83yccw9WpA,2501
44
44
  nucliadb_utils/storages/gcs.py,sha256=KR267zRvBBjT0ksxcfCCz0CmqPD8W-Kj3_lWZXWFg0Q,29249
45
- nucliadb_utils/storages/local.py,sha256=USEYXavJfTK5bU71iLozVM9XjDdtPNte3uWJBuiWIOo,11371
45
+ nucliadb_utils/storages/local.py,sha256=2aCHpZymORG_dUc1FDq0VFcgQulu0w2pZiUaj9dphFs,11686
46
46
  nucliadb_utils/storages/nuclia.py,sha256=vEv94xAT7QM2g80S25QyrOw2pzvP2BAX-ADgZLtuCVc,2097
47
47
  nucliadb_utils/storages/object_store.py,sha256=2PueRP5Q3XOuWgKhj6B9Kp2fyBql5np0T400YRUbqn4,4535
48
48
  nucliadb_utils/storages/s3.py,sha256=4-cs_uFC4ZoLHLTZqvGi8v3nQcbrPBFJZuIeWltkFHI,21026
49
49
  nucliadb_utils/storages/settings.py,sha256=ugCPy1zxBOmA2KosT-4tsjpvP002kg5iQyi42yCGCJA,1285
50
- nucliadb_utils/storages/storage.py,sha256=zs3FE5TNQAT9VbV6RVxMFr9wxaX1FLAC8U_iupb1nf8,21661
50
+ nucliadb_utils/storages/storage.py,sha256=mAP4u_96yXmmbFOWxqFiIDcgiUeZ-Jj_ev466ifdnmo,21859
51
51
  nucliadb_utils/storages/utils.py,sha256=8g2rIwJeYIumQLOB47Yw1rx3twlhRB_cJxer65QfZmk,1479
52
52
  nucliadb_utils/tests/__init__.py,sha256=Oo9CAE7B0eW5VHn8sHd6o30SQzOWUhktLPRXdlDOleA,1456
53
53
  nucliadb_utils/tests/asyncbenchmark.py,sha256=vrX_x9ifCXi18PfNShc23w9x_VUiB_Ph-2nuolh9z3Q,10707
@@ -57,7 +57,7 @@ nucliadb_utils/tests/gcs.py,sha256=MBMzn_UHU5SU6iILuCsB5zU4umhNcaCw_MKrxZhwvOc,4
57
57
  nucliadb_utils/tests/local.py,sha256=cxIfPrKuqs5Ef0nbrVYQQAH2mwc4E0iD9bC2sWegS-c,1934
58
58
  nucliadb_utils/tests/nats.py,sha256=RWHjwqq5esuO7OFbP24yYX1cXnpPLcWJwDUdmwCpH28,1897
59
59
  nucliadb_utils/tests/s3.py,sha256=DACUh3HvgH3BchKFZ9R7RFUzsrg3v9A-cxTcXx4nmvA,3734
60
- nucliadb_utils-6.3.1.post3577.dist-info/METADATA,sha256=2evgc4ko5-193YzHtap4jt_jVP6LdjMcVjWOZCTpW60,2209
61
- nucliadb_utils-6.3.1.post3577.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
62
- nucliadb_utils-6.3.1.post3577.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
63
- nucliadb_utils-6.3.1.post3577.dist-info/RECORD,,
60
+ nucliadb_utils-6.3.1.post3590.dist-info/METADATA,sha256=e3htVWHDJzJA-wHmBmc2ZtG_wS-xM1kE3VOHKhseGzQ,2209
61
+ nucliadb_utils-6.3.1.post3590.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
62
+ nucliadb_utils-6.3.1.post3590.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
63
+ nucliadb_utils-6.3.1.post3590.dist-info/RECORD,,