granular_configuration_language .yaml.file_ops.text

class granular_configuration_language.yaml.file_ops.text.EagerIOTextFile(
path: Path,
exists: bool,
data: str,
)[source]

Bases: object

Type: frozen dataclass

Added in version 2.3.0.

Encapsulates a file that has been read as text.

data: str

Contents of the file, if the file exists, else an empty str

exists: bool

True, if the file exists, else False

path: Path

File path

granular_configuration_language.yaml.file_ops.text.load_text_file(
file: Path,
/,
) EagerIOTextFile[source]

Added in version 2.3.0.

Load the text file as an EagerIOTextFile instance

Parameters:

file (Path) – file path

Returns:

Constructed instance

Return type:

EagerIOTextFile

granular_configuration_language.yaml.file_ops.text.read_text_data(
filename: Path | EagerIOTextFile,
/,
) str[source]

Added in version 2.3.0.

Read file contents.

Whether it is already loaded (as an EagerIOTextFile instance) or as a Path

Parameters:

filename (Path | EagerIOTextFile) – File path

Raises:

FileNotFoundError – Errors if the file does not exist.

Returns:

File contents.

Return type:

str