Esempio n. 1
0
def data_tree_map(func, data_tree):
    '''
    Map func to every ABITypedData element in the tree. func will
    receive two args: abi_type, and data
    '''
    def map_to_typed_data(elements):
        if isinstance(elements, ABITypedData) and elements.abi_type is not None:
            return ABITypedData(func(*elements))
        else:
            return elements
    return recursive_map(map_to_typed_data, data_tree)
Esempio n. 2
0
def data_tree_map(func, data_tree):
    '''
    Map func to every ABITypedData element in the tree. func will
    receive two args: abi_type, and data
    '''
    def map_to_typed_data(elements):
        if isinstance(elements, ABITypedData) and elements.abi_type is not None:
            return ABITypedData(func(*elements))
        else:
            return elements
    return recursive_map(map_to_typed_data, data_tree)
Esempio n. 3
0
 def recursive(cls, value):
     return recursive_map(cls._apply_if_mapping, value)
Esempio n. 4
0
def test_recursive_collection_cycle():
    data = [3]
    data.append(data)
    with pytest.raises(ValueError):
        recursive_map(square_int, data)
Esempio n. 5
0
def test_recursive_collection_apply():
    assert recursive_map(square_int, [[3]]) == [[9]]
Esempio n. 6
0
 def recursive(cls, value):
     return recursive_map(cls._apply_if_mapping, value)