Yaml parser

class odin.source.core.yaml_parser.Parser(filepath=None, data=None)

Yaml parser.

Usage:

p = Parser.open(‘filepath’)

p.filepath = ‘your/new/file/path.yaml’

p.data = {‘new’: ‘data’}

Parameters
  • filepath (str) – path/of/your/file.yaml

  • data (dict) – data to put in the yaml file

Return type

None

classmethod new(filepath, data=None)

Create a new yaml file.

Parameters
  • filepath (str) – filepath of the yaml file

  • data (Optional[Dict[str]]) –

Return type

Parser

Returns

Parser object that contain the new yaml file with its data

classmethod open(filepath)

Generate a Parser object from the given yaml file.

Parameters

filepath (str) – yaml file path to open

Return type

Union[Parser, None]

Returns

Parser object that contain the yaml file with its data

Raises

IOError – if the file specified does not exist

write(data=None)

Write the data in the yaml file.

Raises

RuntimeError – if the file does not exist

Return type

None

Parameters

data (Optional[dict]) –