Storages abstracts#

Storage abstraction include some methods to perform storage validation and collection.

class diskette.core.storages.StorageMixin[source]#

Storage manager is in charge to collect storage file paths.

Note

self.storages_basepath value determine if storages are valid (they must be a children of it) and how they will be stored in archive since they are made relative from the storages_basepath

validate_storages()[source]#

Validate every storage path defined from settings.

A storage path must be a Path object, exists on filesystem and must be a directory.

Raises:

DumperError – In case of error with a storage path.

Returns:

Returns True if all storage has been validated.

Return type:

boolean

is_allowed_path(path)[source]#

Check if given path match is allowed to be collected depending it match or not any exclusion patterns.

Parameters:

path (Path) – Path to check against exclusion patterns.

Returns:

True if path is allowed from exclusion patterns, else False.

Return type:

boolean

iter_storages_files(allow_excludes=True)[source]#

Iterate over all storages files.

Keyword Arguments:

allow_excludes (boolean) – To enable storage content exclusion using defined exclusion patterns. Default value enables it.

Returns:

Iterator for all storages files.

Return type:

iterator

class diskette.core.storages.StorageManager(storages_basepath=None, storages=None, storages_excludes=None, logger=None)[source]#

Concrete basic implementation for StorageMixin.

Keyword Arguments:
  • storages_basepath (Path) – Basepath for reference in some path resolution. Currently used by storage dump to make relative path for storage files. On default this is based on current working directory. If given, the storage paths must be in the same leaf else this will be an error.

  • storages (list) – A list of storage Path objects.

  • storages_excludes (list) – A list of patterns to exclude storage files from dump.

  • logger (object) – Instance of a logger object to use. Logger object must implement common logging message methods (like error, info, etc..). See diskette.utils.loggers for available loggers. If not given, a dummy logger will be used that ignores any messages and won’t output anything.