labpack/mapping/data.py
def walk_data(input_data):

    ''' a generator function for retrieving data in a nested dictionary

    :param input_data: dictionary or list with nested data
    :return: string with dot_path, object with value of endpoint
    '''

    def _walk_dict(input_dict, path_to_root):
        if not path_to_root:
            yield '.', input_dict
        for key, value in input_dict.items():
            key_path = '%s.%s' % (path_to_root, key)
            type_name = value.__class__.__name__
            yield key_path, value
            if type_name == 'dict':
                for dot_path, value in _walk_dict(value, key_path):
                    yield dot_path, value
            elif type_name == 'list':
                for dot_path, value in _walk_list(value, key_path):
                    yield dot_path, value

    def _walk_list(input_list, path_to_root):
        for i in range(len(input_list)):
            item_path = '%s[%s]' % (path_to_root, i)
            type_name = input_list[i].__class__.__name__
            yield item_path, input_list[i]
            if type_name == 'dict':
                for dot_path, value in _walk_dict(input_list[i], item_path):
                    yield dot_path, value
            elif type_name == 'list':
                for dot_path, value in _walk_list(input_list[i], item_path):
                    yield dot_path, value

    if isinstance(input_data, dict):
        for dot_path, value in _walk_dict(input_data, ''):
            yield dot_path, value
    elif isinstance(input_data, list):
        for dot_path, value in _walk_list(input_data, ''):
            yield dot_path, value
    else:
        raise ValueError('walk_data() input_data argument must be a list or dictionary.')
 a generator function for retrieving data in a nested dictionary

    :param input_data: dictionary or list with nested data
    :return: string with dot_path, object with value of endpoint
    
a generator function for retrieving data in a nested dictionary
a generator function for retrieving data in a nested dictionary
def walk_data(input_data):
    def _walk_dict(input_dict, path_to_root):
        if not path_to_root:
            yield '.', input_dict
        for key, value in input_dict.items():
            key_path = '%s.%s' % (path_to_root, key)
            type_name = value.__class__.__name__
            yield key_path, value
            if type_name == 'dict':
                for dot_path, value in _walk_dict(value, key_path):
                    yield dot_path, value
            elif type_name == 'list':
                for dot_path, value in _walk_list(value, key_path):
                    yield dot_path, value
    def _walk_list(input_list, path_to_root):
        for i in range(len(input_list)):
            item_path = '%s[%s]' % (path_to_root, i)
            type_name = input_list[i].__class__.__name__
            yield item_path, input_list[i]
            if type_name == 'dict':
                for dot_path, value in _walk_dict(input_list[i], item_path):
                    yield dot_path, value
            elif type_name == 'list':
                for dot_path, value in _walk_list(input_list[i], item_path):
                    yield dot_path, value
    if isinstance(input_data, dict):
        for dot_path, value in _walk_dict(input_data, ''):
            yield dot_path, value
    elif isinstance(input_data, list):
        for dot_path, value in _walk_list(input_data, ''):
            yield dot_path, value
    else:
        raise ValueError('walk_data() input_data argument must be a list or dictionary.')
def walk_data ( input_data ) : def _walk_dict ( input_dict , path_to_root ) : if not path_to_root : yield '.' , input_dict for key , value in input_dict . items ( ) : key_path = '%s.%s' % ( path_to_root , key ) type_name = value . __class__ . __name__ yield key_path , value if type_name == 'dict' : for dot_path , value in _walk_dict ( value , key_path ) : yield dot_path , value elif type_name == 'list' : for dot_path , value in _walk_list ( value , key_path ) : yield dot_path , value def _walk_list ( input_list , path_to_root ) : for i in range ( len ( input_list ) ) : item_path = '%s[%s]' % ( path_to_root , i ) type_name = input_list [ i ] . __class__ . __name__ yield item_path , input_list [ i ] if type_name == 'dict' : for dot_path , value in _walk_dict ( input_list [ i ] , item_path ) : yield dot_path , value elif type_name == 'list' : for dot_path , value in _walk_list ( input_list [ i ] , item_path ) : yield dot_path , value if isinstance ( input_data , dict ) : for dot_path , value in _walk_dict ( input_data , '' ) : yield dot_path , value elif isinstance ( input_data , list ) : for dot_path , value in _walk_list ( input_data , '' ) : yield dot_path , value else : raise ValueError ( 'walk_data() input_data argument must be a list or dictionary.' )
a generator function for retrieving data in a nested dictionary
a generator function for retrieving data in a nested dictionary
''' a generator function for retrieving data in a nested dictionary

    :param input_data: dictionary or list with nested data
    :return: string with dot_path, object with value of endpoint
    '''
string with dot_path, object with value of endpoint
string with dot_path object with value of endpoint
input_data
dictionary or list with nested data
dictionary or list with nested data