eradiate.data.SafeDirectoryDataStore#

class eradiate.data.SafeDirectoryDataStore(path, registry_fname='registry.txt')[source]#

Bases: DataStore

Serve files stored in a directory. This data store will only serve files listed in its registry.

Parameters:
  • path (path-like) – Path to the root of the directory referenced by this data store.

  • registry_fname (path-like, default: "registry.txt") – Path to the registry file, relative to path.

Fields:
  • path (Path) – Path to the root of the directory referenced by this data store.

  • registry_fname (Path) – Path to the registry file, relative to path.

fetch(filename, **kwargs)[source]#

Fetch a file from the data store.

Parameters:

filename (path-like) – File name to fetch from the data store, relative to the storage root.

Returns:

Path – Absolute path where the retrieved resource is located.

Raises:

DataError – The requested file could not be served.

registry_delete()[source]#

Delete the registry file.

registry_fetch()[source]#

Get the absolute path to the registry file. If no file exists, one will be created based on the rules contained defined in self.path / "registry_rules.yml".

registry_files(filter=None)[source]#

Get a list of registered files.

Parameters:

filter (callable(), optional) – A filter function taking a file path as a single string argument and returning a boolean. Filenames for which the filter returns True will be returned.

Returns:

files (list of str) – List of registered files.

registry_make()[source]#

Generate a registry file from the contents of the self.path directory, according to inclusion and exclusion rules defined in the self.path / "registry_rules.yml" file. The generated registry is written to self.path / self.registry_fname.

registry_reload()[source]#

Reload the registry file from the hard drive.

property base_url#

Address of the remote storage location.

Type:

str

property registry#

Registry contents.

Type:

dict

property registry_path#

Path to the registry file.

Type:

Path