swh.objstorage.objstorage module#

swh.objstorage.objstorage.objid_to_default_hex(obj_id: Union[bytes, CompositeObjId]) str[source]#

Converts SHA1 hashes and multi-hashes to the hexadecimal representation of the SHA1.

swh.objstorage.objstorage.compute_hash(content, algo='sha1')[source]#

Compute the content’s hash.

Parameters:
  • content (bytes) – The raw content to hash

  • hash_name (str) – Hash’s name (default to ID_HASH_ALGO)

Returns:

The ID_HASH_ALGO for the content

class swh.objstorage.objstorage.NullCompressor[source]#

Bases: object

compress(data)[source]#
flush()[source]#
class swh.objstorage.objstorage.NullDecompressor[source]#

Bases: object

decompress(data: bytes) bytes[source]#
property unused_data: bytes#
class swh.objstorage.objstorage.ObjStorage(*, allow_delete=False, **kwargs)[source]#

Bases: object

add_batch(contents: Union[Mapping[bytes, bytes], Iterable[Tuple[Union[bytes, CompositeObjId], bytes]]], check_presence: bool = True) Dict[source]#
restore(content: bytes, obj_id: Union[bytes, CompositeObjId]) None[source]#
get_batch(obj_ids: Iterable[Union[bytes, CompositeObjId]]) Iterator[Optional[bytes]][source]#
abstract delete(obj_id: Union[bytes, CompositeObjId])[source]#
list_content(last_obj_id: Optional[Union[bytes, CompositeObjId]] = None, limit: Optional[int] = 10000) Iterator[CompositeObjId][source]#