示例#1
0
文件: abi.py 项目: drummonda/pluto
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)
示例#2
0
文件: abi.py 项目: syngraph/web3.py
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)
示例#3
0
 def recursive(cls, value):
     return recursive_map(cls._apply_if_mapping, value)
示例#4
0
def test_recursive_collection_cycle():
    data = [3]
    data.append(data)
    with pytest.raises(ValueError):
        recursive_map(square_int, data)
示例#5
0
def test_recursive_collection_apply():
    assert recursive_map(square_int, [[3]]) == [[9]]
示例#6
0
 def recursive(cls, value):
     return recursive_map(cls._apply_if_mapping, value)