swh.objstorage.backends.generator module#

class swh.objstorage.backends.generator.Randomizer[source]#

Bases: object

read(size)[source]#
swh.objstorage.backends.generator.gen_sizes()[source]#

generates numbers according to the rought distribution of file size in the SWH archive

swh.objstorage.backends.generator.gen_random_content(total=None, filesize=None)[source]#

generates random (file) content which sizes roughly follows the SWH archive file size distribution (by default).

Parameters:
  • total (int) – the total number of objects to generate. Infinite if unset.

  • filesize (int) – generate objects with fixed size instead of random ones.

class swh.objstorage.backends.generator.RandomGeneratorObjStorage(filesize=None, total=None, **kwargs)[source]#

Bases: ObjStorage

A stupid read-only storage that generates blobs for testing purpose.

name: str = 'generator'#

Default objstorage name; can be overloaded at instantiation time giving a ‘name’ argument to the constructor

property content_generator#
check_config(*, check_write)[source]#
get(obj_id, *args, **kwargs)[source]#
add(content, obj_id, check_presence=True, *args, **kwargs)[source]#
check(obj_id, *args, **kwargs)[source]#

Check if a content is found and recompute its hash to check integrity.

delete(obj_id, *args, **kwargs)[source]#
list_content(last_obj_id: bytes | CompositeObjId | None = None, limit: int | None = 10000) Iterator[CompositeObjId][source]#