Input Output core module

FileObjectModelProtocol

Bases: Protocol

is_valid() -> bool

Verifies if the current object is valid for import / export.

Returns:
  • bool( bool ) –

    Result of the validation.

KoswatExporterProtocol

Bases: Protocol

export(**kwargs) -> None

Exports an object model into a concrete file format.

KoswatImporterProtocol

Bases: Protocol

import_from(from_path: Path) -> DataObjectModelProtocol | list[DataObjectModelProtocol]

Generates a valid instance of a DataObjectModelProtocol based on the contents from the provided path.

Parameters:
  • from_path (Path) –

    Path containing data to be read (file or directory).

Returns:

KoswatReaderProtocol

Bases: Protocol

read(file_path: Path) -> FileObjectModelProtocol

Imports the data from the file_path into a concrete implementation of a FileObjectModelProtocol.

Parameters:
  • file_path (Path) –

    Path to a file that should be imported.

Returns:

supports_file(file_path: Path) -> bool

Validates whether the current reader is capable of importing data from the provided file.

Parameters:
  • file_path (Path) –

    Path to a file that should be imported.

Returns:
  • bool( bool ) –

    Result of validation.

KoswatWriterProtocol

Bases: Protocol

write(fom_instance: FileObjectModelProtocol, to_path: Path) -> None

Writes the data from the instance of a FileObjectModelProtocol to the to_path.

Parameters:
  • fom_instance (FileObjectModelProtocol) –

    Instance with data to write.

  • to_path (Path) –

    Path to file (or directory) where to write the data.

CSV module

KoswatCsvFomProtocol

Bases: FileObjectModelProtocol, Protocol

is_valid() -> bool

Validates the current structure of this KoswatCsvFomProtocol instance.

Returns:
  • bool( bool ) –

    True when is a valid FOM.

INI module

KoswatIniFomProtocol

Bases: FileObjectModelProtocol, Protocol

from_config(ini_config: ConfigParser) -> KoswatIniFomProtocol classmethod

Imports all the data stored in an dictionary into a KoswatIniFomProtocol instance.

Parameters:
  • ini_config (ConfigParser) –

    Dictionary containing Ini values (section - properties, property - value) to be parsed.

Returns:
  • KoswatIniFomProtocol( KoswatIniFomProtocol ) –

    Valid instance of a KoswatIniFomProtocol with the provided values.

TXT module

KoswatTxtFomProtocol

Bases: FileObjectModelProtocol, Protocol

from_text(file_text: str) -> KoswatTxtFomProtocol classmethod

Imports all the data stored in text form.

Parameters:
  • file_text (str) –

    Raw data in string format.

Returns:
  • KoswatTxtFomProtocol( KoswatTxtFomProtocol ) –

    Valid instance of a KoswatTxtFomProtocol with the provided values.