toml_dataclass module

Manipulate toml and Python dataclass interchangeably.

Classes:

TomlDataClassIO: Base class for non-tabular toml data.

TomlTableDataClassIO: Base class for tabular toml data.

class toml_dataclass.TomlDataClassIO[source]

Bases: object

Base class for a simple dataclass (i.e. with no mapping types)

T = ~T
classmethod read(stream_in: TextIO) T | None[source]

Create an instance of the derived class from a toml file.

Parameters:
  • source – A filepath or an input stream.

  • stream_in (TextIO) –

Returns:

Instance of the type of cls.

Return type:

T | None

write(stream_out: TextIO)[source]

Write the dataclass as a toml file.

Parameters:
  • target – A filepath or an output stream.

  • stream_out (TextIO) –

class toml_dataclass.TomlTableDataClassIO[source]

Bases: TomlDataClassIO

Base class for a dataclass with a list object (e.g. List[AnotherTomlDataClassIO])

The exposed methods of TomlTableDataClassIO are the same of TomlDataClassIO. What differs both classes are the implementation of internal methods.

T = ~T