def _merge_asized(base, other, level=0):
    """
    Merge **Asized** instances `base` and `other` into `base`.
    """
    ref2key = lambda ref: ref.name.split(':')[0]
    base.size += other.size
    base.flat += other.flat
    if level > 0:
        base.name = ref2key(base)
    # Add refs from other to base. Any new refs are appended.
    base.refs = list(base.refs) # we may need to append items
    refs = {}
    for ref in base.refs:
        refs[ref2key(ref)] = ref
    for ref in other.refs:
        key = ref2key(ref)
        if key in refs:
            _merge_asized(refs[key], ref, level=level+1)
        else:
            # Don't modify existing Asized instances => deepcopy
            base.refs.append(deepcopy(ref))
            base.refs[-1].name = key
def _merge_asized ( base , other , level = 0 ) : ref2key = lambda ref : ref . name . split ( ':' ) [ 0 ] base . size += other . size base . flat += other . flat if level > 0 : base . name = ref2key ( base ) base . refs = list ( base . refs ) refs = { } for ref in base . refs : refs [ ref2key ( ref ) ] = ref for ref in other . refs : key = ref2key ( ref ) if key in refs : _merge_asized ( refs [ key ] , ref , level = level + 1 ) else : base . refs . append ( deepcopy ( ref ) ) base . refs [ - 1 ] . name = key
Merge **Asized** instances `base` and `other` into `base`.