Parse a structured exchange list as obtained from a YAML file.

    Yields tuples of compound, reaction ID, lower and upper flux bounds. Path
    can be given as a string or a context.

def parse_exchange_list(path, exchange, default_compartment):
    """Parse a structured exchange list as obtained from a YAML file.

    Yields tuples of compound, reaction ID, lower and upper flux bounds. Path
    can be given as a string or a context.
    """

    context = FilePathContext(path)

    for exchange_def in exchange:
        if 'include' in exchange_def:
            include_context = context.resolve(exchange_def['include'])
            for exchange_compound in parse_exchange_file(
                    include_context, default_compartment):
                yield exchange_compound
        else:
            for exchange_compound in parse_exchange(
                    exchange_def, default_compartment):
                yield exchange_compound