Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/api/client.py
Show All 24 Lines | Attributes: | ||||
session: The session to send requests. | session: The session to send requests. | ||||
""" | """ | ||||
api_exception = ObjStorageAPIError | api_exception = ObjStorageAPIError | ||||
reraise_exceptions = [ObjNotFoundError, Error] | reraise_exceptions = [ObjNotFoundError, Error] | ||||
backend_class = ObjStorageInterface | backend_class = ObjStorageInterface | ||||
def restore(self: ObjStorageInterface, content: bytes, obj_id: ObjId): | def restore(self: ObjStorageInterface, content: bytes, obj_id: ObjId) -> None: | ||||
return self.add(content, obj_id, check_presence=False) | return self.add(content, obj_id, check_presence=False) | ||||
ardumont: the return is no longer needed then. | |||||
def __iter__(self): | def __iter__(self): | ||||
yield from self.list_content() | yield from self.list_content() | ||||
def list_content( | def list_content( | ||||
self, | self, | ||||
last_obj_id: Optional[ObjId] = None, | last_obj_id: Optional[ObjId] = None, | ||||
limit: int = DEFAULT_LIMIT, | limit: int = DEFAULT_LIMIT, | ||||
) -> Iterator[ObjId]: | ) -> Iterator[ObjId]: | ||||
params = {"limit": limit} | params = {"limit": limit} | ||||
if last_obj_id: | if last_obj_id: | ||||
params["last_obj_id"] = hashutil.hash_to_hex(last_obj_id) | params["last_obj_id"] = hashutil.hash_to_hex(last_obj_id) | ||||
yield from iter_chunks( | yield from iter_chunks( | ||||
self._get_stream("content", params=params), chunk_size=ID_DIGEST_LENGTH | self._get_stream("content", params=params), chunk_size=ID_DIGEST_LENGTH | ||||
) | ) |
the return is no longer needed then.