esm_parser package


esm_parser.esm_parser module

esm_parser.shell_to_dict module

Backwards compatability for old runscripts


Generates a User Config from an old Shellscript

esm_parser.shell_to_dict.mini_recursive_run_func(config, func)[source]

esm_parser.yaml_to_dict module

exception esm_parser.yaml_to_dict.EsmConfigFileError(fpath, yaml_error)[source]

Bases: Exception

Exception for yaml file containing tabs or other syntax issues.

An exception used when yaml.load() throws a yaml.scanner.ScannerError. This error occurs mainly when there are tabs inside a yaml file or when the syntax is incorrect. If tabs are found, this exception returns a user-friendly message indicating where the tabs are located in the yaml file.


fpath (str) – Path to the yaml file

esm_parser.yaml_to_dict.check_changes_duplicates(yamldict_all, fpath)[source]

Checks for duplicates and conflicting _changes and add_:

  1. Finds variables containing _changes (but excluding add_) and checks if they are compatible with the same _changes inside the same file. If they are not compatible returns an error where the conflicting variable paths are specified. More than one _changes type in a file are allowed but they need to be part of the same _choose and not be accessible simultaneously in any situation.

  2. Checks if there is any variable containing add_ in the main sections of a file and labels it as incompatible if the same variable is found inside a choose_ block. add_<variable>``s are compatible as long as they are inside ``choose_ blocks, but if you want to include something as a default, please just do it inside the <variable>.


    add_<variable>``s are not checked for incompatibility when they are included inside ``choose_ blocks. Merging of these add_<variable>``s is done using ``deep_update, meaning that the merge is arbitrary (i.e. if two choose_ blocks are modifying the same variable using add_, the final value would be decided arbitrarily). It is up to the developer/user to make good use of add_``s inside ``choose_ blocks.

  • yamldict_all (dict) – Dictionary read from the yaml file

  • fpath (str) – Path to the yaml file


Checks that there are no duplicates in a yaml file, and if there are returns an error stating which key is repeated and in which file the duplication occurs.

  • src (object) – Source file object

  • Exceptions

  • ----------

  • ConstructorError – If duplicated keys are found, returns an error

esm_parser.yaml_to_dict.create_env_loader(tag='!ENV', loader=<class 'yaml.loader.SafeLoader'>)[source]

Locates the last choose_ on a string containing the path to a variable separated by “,”, and returns the path to the choose_ (also separated by “,”) and the case that follows the choose_.


var_path (str) – String containing the path to the last choose_ separated by “,”.


  • path2choose (str) – Path to the last choose_.

  • case (str) – Case after the choose.


Given a yaml file, returns a corresponding dictionary.

If you do not give an extension, tries again after appending one. It raises an EsmConfigFileError exception if yaml files contain tabs.


filepath (str) – Where to get the YAML file from


A dictionary representation of the yaml file.

Return type


  • EsmConfigFileError – Raised when YAML file contains tabs or other syntax issues.

  • FileNotFoundError – Raised when the YAML file cannot be found and all extensions have been tried.