Page MenuHomeSoftware Heritage
Paste P1043

python function colors
ActivePublic

Authored by vlorentz on May 17 2021, 1:43 PM.
def get(self, obj_id):
"""Retrieve blob's content if found.
"""
hex_obj_id = self._internal_id(obj_id)
client = self.get_blob_client(hex_obj_id)
try:
download = client.download_blob()
except ResourceNotFoundError:
raise ObjNotFoundError(obj_id) from None
else:
data = download.content_as_bytes()
decompressor = decompressors[self.compression]()
ret = decompressor.decompress(data)
if decompressor.unused_data:
raise Error("Corrupt object %s: trailing data found" % hex_obj_id)
return ret
async def _get_async(self, obj_id, container_clients):
"""Like ``get(obj_id)``, but asynchronous"""
hex_obj_id = self._internal_id(obj_id)
client = self.get_async_blob_client(hex_obj_id, container_clients)
try:
download = await client.download_blob()
except ResourceNotFoundError:
raise ObjNotFoundError(obj_id) from None
else:
data = await download.content_as_bytes()
decompressor = decompressors[self.compression]()
ret = decompressor.decompress(data)
if decompressor.unused_data:
raise Error("Corrupt object %s: trailing data found" % hex_obj_id)
return ret