swh.vault.cookers.base module

exception swh.vault.cookers.base.PolicyError[source]

Bases: Exception

Raised when the bundle violates the cooking policy.

exception swh.vault.cookers.base.BundleTooLargeError[source]

Bases: swh.vault.cookers.base.PolicyError

Raised when the bundle is too large to be cooked.

class swh.vault.cookers.base.BytesIOBundleSizeLimit(*args, size_limit=None, **kwargs)[source]

Bases: _io.BytesIO

write(chunk)[source]

Write bytes to file.

Return the number of bytes written.

class swh.vault.cookers.base.BaseVaultCooker(obj_type, obj_id, backend, storage, max_bundle_size=536870912)[source]

Bases: object

Abstract base class for the vault’s bundle creators

This class describes a common API for the cookers.

To define a new cooker, inherit from this class and override: - CACHE_TYPE_KEY: key to use for the bundle to reference in cache - def cook(): cook the object into a bundle

CACHE_TYPE_KEY = None
abstract check_exists()[source]

Checks that the requested object exists and can be cooked.

Override this in the cooker implementation.

abstract prepare_bundle()[source]

Implementation of the cooker. Yields chunks of the bundle bytes.

Override this with the cooker implementation.

write(chunk)[source]
cook()[source]

Cook the requested object into a bundle