Parse a structured list of compounds as obtained from a YAML file

    Yields CompoundEntries. Path can be given as a string or a context.

def parse_compound_list(path, compounds):
    """Parse a structured list of compounds as obtained from a YAML file

    Yields CompoundEntries. Path can be given as a string or a context.
    """

    context = FilePathContext(path)

    for compound_def in compounds:
        if 'include' in compound_def:
            file_format = compound_def.get('format')
            include_context = context.resolve(compound_def['include'])
            for compound in parse_compound_file(include_context, file_format):
                yield compound
        else:
            yield parse_compound(compound_def, context)