Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/cookers/base.py
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | class BaseVaultCooker(metaclass=abc.ABCMeta): | ||||
def __init__( | def __init__( | ||||
self, | self, | ||||
obj_type, | obj_type, | ||||
obj_id, | obj_id, | ||||
backend, | backend, | ||||
storage, | storage, | ||||
graph=None, | graph=None, | ||||
objstorage=None, | |||||
max_bundle_size=MAX_BUNDLE_SIZE, | max_bundle_size=MAX_BUNDLE_SIZE, | ||||
): | ): | ||||
"""Initialize the cooker. | """Initialize the cooker. | ||||
The type of the object represented by the id depends on the | The type of the object represented by the id depends on the | ||||
concrete class. Very likely, each type of bundle will have its | concrete class. Very likely, each type of bundle will have its | ||||
own cooker class. | own cooker class. | ||||
Args: | Args: | ||||
obj_type: type of the object to be cooked into a bundle (directory, | obj_type: type of the object to be cooked into a bundle (directory, | ||||
revision_flat or revision_gitfast; see | revision_flat or revision_gitfast; see | ||||
swh.vault.cooker.COOKER_TYPES). | swh.vault.cooker.COOKER_TYPES). | ||||
obj_id: id of the object to be cooked into a bundle. | obj_id: id of the object to be cooked into a bundle. | ||||
backend: the vault backend (swh.vault.backend.VaultBackend). | backend: the vault backend (swh.vault.backend.VaultBackend). | ||||
""" | """ | ||||
self.obj_type = obj_type | self.obj_type = obj_type | ||||
self.obj_id = hashutil.hash_to_bytes(obj_id) | self.obj_id = hashutil.hash_to_bytes(obj_id) | ||||
self.backend = backend | self.backend = backend | ||||
self.storage = storage | self.storage = storage | ||||
self.objstorage = objstorage | |||||
self.graph = graph | self.graph = graph | ||||
self.max_bundle_size = max_bundle_size | self.max_bundle_size = max_bundle_size | ||||
@abc.abstractmethod | @abc.abstractmethod | ||||
def check_exists(self): | def check_exists(self): | ||||
"""Checks that the requested object exists and can be cooked. | """Checks that the requested object exists and can be cooked. | ||||
Override this in the cooker implementation. | Override this in the cooker implementation. | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |