magmap.io.yaml_io module

YAML file format input/output.

magmap.io.yaml_io.load_yaml(path, enums=None)[source]

Load a YAML file with support for multiple documents and Enums.

Parameters:
  • path (Union[str, Path]) – Path to YAML file.

  • enums (Optional[Dict[str, Enum]], default: None) – Dictionary mapping Enum names to Enum classes; defaults to None. If a key or value in the YAML file matches an Enum name followed by a period, the corresponding Enum will be used.

Return type:

List[Dict]

Returns:

Sequence of parsed dictionaries for each document within a YAML file.

Raises:

FileNotFoundError – if path could not be found or loaded.

magmap.io.yaml_io.save_yaml(path, data, use_primitives=False, convert_enums=False)[source]

Save a dictionary to YAML file format.

Parameters:
  • path (Union[str, Path]) – Output path.

  • data (Dict) – Dictionary to output.

  • use_primitives (bool, default: False) – True to replace Numpy data types with Python primitives; defaults to False.

  • convert_enums (bool, default: False) – True to convert keys and vals that are Enums to strings; defaults to False.

Return type:

Dict

Returns:

data with any conversions.