devana.preprocessing.premade.components.savers

devana.preprocessing.premade.components.savers.filesaver

class FileSaver(configuration)[source]

Bases: IDestination

Implementation that provides text file saving. It supports dynamically generated paths (in real use, probably based on the file extension extracted from the name) and supports defined path prefixes.

class Configuration(root_path, path_prefix_generator=None)[source]

Bases: object

Core FileSaver configuration

path_prefix_generator: Optional[Callable[[IDestiny], Path]] = None

If it exists, the function is called for each IDestiny and the generated prefix is appended after the fixed prefix from the IDestiny.

root_path: Path

Base path relative to which prefixes are added.

property configuration: Configuration

Current configuration.

Return type

Configuration

consume(data)[source]

Consume data from generator and save it.

Return type

Optional[Artifacts]

classmethod get_required_type()[source]

Specifies the required input type. In common cases should be interfaced.

Return type

Type

class IDestiny[source]

Bases: ABC

The basic element on which FileSaver operates.

abstract property content: str

The contents of the file as test - it will be saved.

Return type

str

abstract property name: str

The name of the file, including the extension. This will be used to save as the file name.

Return type

str

abstract property path_prefix: Optional[Path]

If set, it will be added to the root write path after which further path modifications are allowed.

Return type

Optional[Path]

Classes that implement the interface to provide file writing functionality.