labpack/compilers/yaml.py
def merge_yaml(*sources, output=''):
    
    '''
        method for merging two or more yaml strings

    this method walks the parse tree of yaml data to merge the fields
    (and comments) found in subsequent sources into the data structure of the
    initial sources. any number of sources can be added to the source args, but
    only new fields and new comments from subsequent sources will be added. to
    overwrite the values in the initial source, it suffices to simply reverse 
    the order of the sources

    PLEASE NOTE:    since there is no way to uniquely identify list items between
                    two yaml documents, items are not added to existing lists.
                    the overwrite rule also has no effect on items in lists

    PLEASE NOTE:    however, lists are transversed in order to evaluate comments
                    and keys of nested dictionaries using the first item of any
                    subsequent list as a model for the scope

    PLEASE NOTE:    the way that ruamel.yaml keeps track of multi-line comments
                    can create odd results for comments which appear at the start
                    or the end of lists and dictionaries when new fields and comments 
                    are added. it is best to restrict comments to the start of lists
                    and dictionaries.

    PLEASE NOTE:    this method makes no checks to ensure the file path of the 
                    sources exist nor the folder path to any output

    :param sources: variable-length argument list of strings with path to yaml files
    :param output: [optional] string with path to save the combined yaml data to file
    :return: string with merged data
    '''

    # open and combine sources
    src = [ open(yaml_path).read() for yaml_path in sources ]
    stream = merge_yaml_strings(*src, output='io')

    # save to file and return combined string
    if output:
        from shutil import copyfileobj
        with open(output, 'w') as f:
            stream.seek(0)
            copyfileobj(stream, f)
            f.close()
    return stream.getvalue()

        method for merging two or more yaml strings

    this method walks the parse tree of yaml data to merge the fields
    (and comments) found in subsequent sources into the data structure of the
    initial sources. any number of sources can be added to the source args, but
    only new fields and new comments from subsequent sources will be added. to
    overwrite the values in the initial source, it suffices to simply reverse 
    the order of the sources

    PLEASE NOTE:    since there is no way to uniquely identify list items between
                    two yaml documents, items are not added to existing lists.
                    the overwrite rule also has no effect on items in lists

    PLEASE NOTE:    however, lists are transversed in order to evaluate comments
                    and keys of nested dictionaries using the first item of any
                    subsequent list as a model for the scope

    PLEASE NOTE:    the way that ruamel.yaml keeps track of multi-line comments
                    can create odd results for comments which appear at the start
                    or the end of lists and dictionaries when new fields and comments 
                    are added. it is best to restrict comments to the start of lists
                    and dictionaries.

    PLEASE NOTE:    this method makes no checks to ensure the file path of the 
                    sources exist nor the folder path to any output

    :param sources: variable-length argument list of strings with path to yaml files
    :param output: [optional] string with path to save the combined yaml data to file
    :return: string with merged data
    
method for merging two or more yaml strings
this method walks the parse tree of yaml data to merge the fields
(and comments) found in subsequent sources into the data structure of the
initial sources. any number of sources can be added to the source args, but
only new fields and new comments from subsequent sources will be added. to
overwrite the values in the initial source, it suffices to simply reverse
the order of the sources

PLEASE NOTE:    since there is no way to uniquely identify list items between
two yaml documents, items are not added to existing lists.
the overwrite rule also has no effect on items in lists

PLEASE NOTE:    however, lists are transversed in order to evaluate comments
and keys of nested dictionaries using the first item of any
subsequent list as a model for the scope

PLEASE NOTE:    the way that ruamel.yaml keeps track of multi-line comments
can create odd results for comments which appear at the start
or the end of lists and dictionaries when new fields and comments
are added. it is best to restrict comments to the start of lists
and dictionaries.

PLEASE NOTE:    this method makes no checks to ensure the file path of the
sources exist nor the folder path to any output
method for merging two or more yaml strings this method walks the parse tree of yaml data to merge the fields ( and comments ) found in subsequent sources into the data structure of the initial sources . any number of sources can be added to the source args but only new fields and new comments from subsequent sources will be added . to overwrite the values in the initial source it suffices to simply reverse the order of the sources PLEASE NOTE : since there is no way to uniquely identify list items between two yaml documents items are not added to existing lists . the overwrite rule also has no effect on items in lists PLEASE NOTE : however lists are transversed in order to evaluate comments and keys of nested dictionaries using the first item of any subsequent list as a model for the scope PLEASE NOTE : the way that ruamel . yaml keeps track of multi - line comments can create odd results for comments which appear at the start or the end of lists and dictionaries when new fields and comments are added . it is best to restrict comments to the start of lists and dictionaries . PLEASE NOTE : this method makes no checks to ensure the file path of the sources exist nor the folder path to any output
def merge_yaml(*sources, output=''):
    src = [ open(yaml_path).read() for yaml_path in sources ]
    stream = merge_yaml_strings(*src, output='io')
    if output:
        from shutil import copyfileobj
        with open(output, 'w') as f:
            stream.seek(0)
            copyfileobj(stream, f)
            f.close()
    return stream.getvalue()
def merge_yaml ( * sources , output = '' ) : src = [ open ( yaml_path ) . read ( ) for yaml_path in sources ] stream = merge_yaml_strings ( * src , output = 'io' ) if output : from shutil import copyfileobj with open ( output , 'w' ) as f : stream . seek ( 0 ) copyfileobj ( stream , f ) f . close ( ) return stream . getvalue ( )
method for merging two or more yaml strings
this method walks the parse tree of yaml data to merge the fields
(and comments) found in subsequent sources into the data structure of the
initial sources.
method for merging two or more yaml strings this method walks the parse tree of yaml data to merge the fields ( and comments ) found in subsequent sources into the data structure of the initial sources .
'''
        method for merging two or more yaml strings

    this method walks the parse tree of yaml data to merge the fields
    (and comments) found in subsequent sources into the data structure of the
    initial sources. any number of sources can be added to the source args, but
    only new fields and new comments from subsequent sources will be added. to
    overwrite the values in the initial source, it suffices to simply reverse 
    the order of the sources

    PLEASE NOTE:    since there is no way to uniquely identify list items between
                    two yaml documents, items are not added to existing lists.
                    the overwrite rule also has no effect on items in lists

    PLEASE NOTE:    however, lists are transversed in order to evaluate comments
                    and keys of nested dictionaries using the first item of any
                    subsequent list as a model for the scope

    PLEASE NOTE:    the way that ruamel.yaml keeps track of multi-line comments
                    can create odd results for comments which appear at the start
                    or the end of lists and dictionaries when new fields and comments 
                    are added. it is best to restrict comments to the start of lists
                    and dictionaries.

    PLEASE NOTE:    this method makes no checks to ensure the file path of the 
                    sources exist nor the folder path to any output

    :param sources: variable-length argument list of strings with path to yaml files
    :param output: [optional] string with path to save the combined yaml data to file
    :return: string with merged data
    ''' # open and combine sources # save to file and return combined string
string with merged data
string with merged data
output
[optional] string with path to save the combined yaml data to file
[ optional ] string with path to save the combined yaml data to file
sources
variable-length argument list of strings with path to yaml files
variable - length argument list of strings with path to yaml files