graphit/graph_io/io_yaml_format.py
def read_yaml(yaml_file, graph=None, **kwargs):
    """
    Parse (hierarchical) YAML data structure to a graph

    Additional keyword arguments (kwargs) are passed to `read_pydata`
    
    :param yaml_file:      yaml data to parse
    :type yaml_file:       File, string, stream or URL
    :param graph:          Graph object to import dictionary data in
    :type graph:           :graphit:Graph
    
    :return:               GraphAxis object
    :rtype:                :graphit:GraphAxis
    """
    
    # Try parsing the string using default Python yaml parser
    yaml_file = open_anything(yaml_file)
    try:
        yaml_file = yaml.safe_load(yaml_file)
    except IOError:
        logger.error('Unable to decode YAML string')
        return
    
    if not isinstance(yaml_file, list):
        yaml_file = [yaml_file]
    
    base_graph = read_pydata(yaml_file[0], graph=graph, **kwargs)
    
    for yaml_object in yaml_file[1:]:
        sub_graph = read_pydata(yaml_object)
        
        # If sub-graph root is of type 'root', connect children to base_graph
        root = sub_graph.getnodes(sub_graph.root)
        if root[sub_graph.key_tag] == 'root':
            links = [(base_graph.root, child) for child in root.children(return_nids=True)]
        else:
            links = [(base_graph.root, sub_graph.root)]
        
        graph_join(base_graph, sub_graph, links=links)
    
    return base_graph

    Parse (hierarchical) YAML data structure to a graph

    Additional keyword arguments (kwargs) are passed to `read_pydata`
    
    :param yaml_file:      yaml data to parse
    :type yaml_file:       File, string, stream or URL
    :param graph:          Graph object to import dictionary data in
    :type graph:           :graphit:Graph
    
    :return:               GraphAxis object
    :rtype:                :graphit:GraphAxis
    
Parse (hierarchical) YAML data structure to a graph
Additional keyword arguments (kwargs) are passed to `read_pydata`
Parse ( hierarchical ) YAML data structure to a graph Additional keyword arguments ( kwargs ) are passed to ` read_pydata `
def read_yaml(yaml_file, graph=None, **kwargs):
    yaml_file = open_anything(yaml_file)
    try:
        yaml_file = yaml.safe_load(yaml_file)
    except IOError:
        logger.error('Unable to decode YAML string')
        return
    if not isinstance(yaml_file, list):
        yaml_file = [yaml_file]
    base_graph = read_pydata(yaml_file[0], graph=graph, **kwargs)
    for yaml_object in yaml_file[1:]:
        sub_graph = read_pydata(yaml_object)
        root = sub_graph.getnodes(sub_graph.root)
        if root[sub_graph.key_tag] == 'root':
            links = [(base_graph.root, child) for child in root.children(return_nids=True)]
        else:
            links = [(base_graph.root, sub_graph.root)]
        graph_join(base_graph, sub_graph, links=links)
    return base_graph
def read_yaml ( yaml_file , graph = None , ** kwargs ) : yaml_file = open_anything ( yaml_file ) try : yaml_file = yaml . safe_load ( yaml_file ) except IOError : logger . error ( 'Unable to decode YAML string' ) return if not isinstance ( yaml_file , list ) : yaml_file = [ yaml_file ] base_graph = read_pydata ( yaml_file [ 0 ] , graph = graph , ** kwargs ) for yaml_object in yaml_file [ 1 : ] : sub_graph = read_pydata ( yaml_object ) root = sub_graph . getnodes ( sub_graph . root ) if root [ sub_graph . key_tag ] == 'root' : links = [ ( base_graph . root , child ) for child in root . children ( return_nids = True ) ] else : links = [ ( base_graph . root , sub_graph . root ) ] graph_join ( base_graph , sub_graph , links = links ) return base_graph
Parse (hierarchical) YAML data structure to a graph
Additional keyword arguments (kwargs) are passed to `read_pydata`
Parse ( hierarchical ) YAML data structure to a graph Additional keyword arguments ( kwargs ) are passed to ` read_pydata `
"""
    Parse (hierarchical) YAML data structure to a graph

    Additional keyword arguments (kwargs) are passed to `read_pydata`
    
    :param yaml_file:      yaml data to parse
    :type yaml_file:       File, string, stream or URL
    :param graph:          Graph object to import dictionary data in
    :type graph:           :graphit:Graph
    
    :return:               GraphAxis object
    :rtype:                :graphit:GraphAxis
    """ # Try parsing the string using default Python yaml parser # If sub-graph root is of type 'root', connect children to base_graph
None
:graphit:GraphAxis
yaml_file
yaml data to parse
yaml data to parse
graph
Graph object to import dictionary data in
Graph object to import dictionary data in