def json_to_dot_dict()

in common_components/monitoring/json_to_dot.py [0:0]


def json_to_dot_dict(data):
    """ Convert incoming JSON node list into a set of
        python formatted dictionary.
    """
    nodes = {}
    for node in data:
        name = clean_name(node['name'])
        nodes[name] = {
            'name': node['name'],
            'start_time': None,
            'end_time': None,
            'depends_on': [clean_name(x) for x in node['depends_on']],
        }
        if node['end_time']:
            nodes[name]['end_time'] = (datetime.datetime
                                       .fromisoformat(node['end_time'])
                                       .timestamp())
        if node['start_time']:
            nodes[name]['start_time'] = (datetime.datetime
                                         .fromisoformat(node['start_time'])
                                         .timestamp())
    return nodes