omd2tex.tools.class_constructor#

Classes

ClassConstructor([class_name])

class omd2tex.tools.class_constructor.ClassConstructor(class_name: str = 'Config')[source]#

Bases: object

from_file(file_path: str) ConfigBase[source]#

Create a configuration instance from a JSON or YAML file.

Parameters:

file_path – Path to the configuration file.

Returns:

Instantiated ConfigBase subclass populated with file contents.

Raises:
  • FileNotFoundError – If the file is absent.

  • ValueError – If the file has an unsupported extension.

  • json.JSONDecodeError or yaml.YAMLError – If parsing fails.

from_dict(data: Dict[str, Any]) ConfigBase[source]#

Create a configuration instance directly from a dictionary.

to_py_file(file_path: str) None[source]#

Serialize the generated configuration class to a Python file.

Parameters:

file_path – Destination path; .py is appended if missing.

Returns:

None

Raises:
  • ValueError – If configuration has not been built prior to writing.

  • IOError – Propagated on file write errors.