Recursively call op(d) for all list subelements and dictionary 'values' that d may have.
420078
def visit(d, op):
    """"""
    op(d)
    if isinstance(d, list):
        for i in d:
            visit(i, op)
    elif isinstance(d, dict):
        for i in itervalues(d):
            visit(i, op)
548070
def values_at(self, depth):
        
        if depth < 1:
            yield self
        else:
            for dict_tree in self.values():
                for value in dict_tree.values_at(depth - 1):
                    yield value
866829
def _iter_valid_subtotal_dicts(self):
        """"""
        for insertion_dict in self._insertion_dicts:
            # ---skip any non-dicts---
            if not isinstance(insertion_dict, dict):
                continue

            # ---skip any non-subtotal insertions---
            if insertion_dict.get("function") != "subtotal":
                continue

            # ---skip any malformed subtotal-dicts---
            if not {"anchor", "args", "name"}.issubset(insertion_dict.keys()):
                continue

            # ---skip if doesn't reference at least one non-missing element---
            if not self._element_ids.intersection(insertion_dict["args"]):
                continue

            # ---an insertion-dict that successfully runs this gauntlet
            # ---is a valid subtotal dict
            yield insertion_dict
1194394
def call(node: Node, key: str, value: Any):
    """"""
    value = _to_list(value)
    if not value or not isinstance(value[-1], dict):
        value.append({})
    args = value[0:-1]
    kwargs = value[-1]
    node.__dict__[key](*args, **kwargs)
262646
def keys_with_value(dictionary, value):
        ""

        subset = [key for key in dictionary if dictionary[key] == value]

        return subset
951258
def sub_split_values(self, sub):
        
        for i, arr in enumerate(self.splits):
            self.split_map[i] = [sub.get(x, x) for x in arr]
        for split in self.surrogates:
            split.sub_split_values(sub)
1048187
def v_depth(d, depth):
        
        if depth == 0:
            yield d
        else:
            for node in DictTree.v(d):
                for node1 in DictTree.v_depth(node, depth-1):
                    yield node1
806236
def _objs_opts(objs, all=None, **opts):
    '''
    '''
    if objs:  # given objects
        t = objs
    elif all in (False, None):
        t = ()
    elif all is True:  # 'all' objects ...
         # ... modules first, globals and stack
         # (may contain duplicate objects)
        t = tuple(_values(sys.modules)) + (
            globals(), stack(sys.getrecursionlimit())[2:])
    else:
        raise ValueError('invalid option: %s=%r' % ('all', all))
    return t, opts
187406
def recursive_iter(enumerables):
    '''
    
    '''
    if not is_collection(enumerables) or isinstance(enumerables, (basestring, dict)):
        yield enumerables
    else:
        for elem in enumerables:
            for sub_elem in recursive_iter(elem):
                yield sub_elem
605100
def _get_by(key, val, l):
    
    return [x for x in l if _check_value_recursively(key, val, x)]
308683
def recursive_apply(inval, func):
    '''
    '''
    if isinstance(inval, dict):
        return {k: recursive_apply(v, func) for k, v in inval.items()}
    elif isinstance(inval, list):
        return [recursive_apply(v, func) for v in inval]
    else:
        return func(inval)
1009983
def _append_value(self, v_values, next_value, v_idx=None, n_vals=1):
        """"""
        for _ in range(n_vals):
            if v_idx:
                try:
                    v_i = next(v_idx)
                except StopIteration:
                    # Repeating commas are null-statements and can be ignored
                    # Otherwise, we warn the user that this is a bad namelist
                    if next_value is not None:
                        warnings.warn('f90nml: warning: Value {0} is not assigned to '
                              'any variable and has been removed.'
                              ''.format(next_value))

                    # There are more values than indices, so we stop here
                    break

                v_s = [self.default_start_index if idx is None else idx
                       for idx in v_idx.first]

                if not self.row_major:
                    v_i = v_i[::-1]
                    v_s = v_s[::-1]

                # Multidimensional arrays
                if not self.sparse_arrays:
                    pad_array(v_values, list(zip(v_i, v_s)))

                # We iterate inside the v_values and inspect successively
                # deeper lists within the list tree.  If the requested index is
                # missing, we re-size that particular entry.
                # (NOTE: This is unnecessary when sparse_arrays is disabled.)

                v_subval = v_values
                for (i_v, i_s) in zip(v_i[:-1], v_s[:-1]):
                    try:
                        v_subval = v_subval[i_v - i_s]
                    except IndexError:
                        size = len(v_subval)
                        v_subval.extend([] for _ in range(size, i_v - i_s + 1))
                        v_subval = v_subval[i_v - i_s]

                # On the deepest level, we explicitly assign the value
                i_v, i_s = v_i[-1], v_s[-1]
                try:
                    v_subval[i_v - i_s] = next_value
                except IndexError:
                    size = len(v_subval)
                    v_subval.extend(None for _ in range(size, i_v - i_s + 1))
                    v_subval[i_v - i_s] = next_value
            else:
                v_values.append(next_value)
594495
def values(self):
    
    if self._data:
      for key in xrange(self.order + 1):
        yield self[key]
783861
def all_subs(bounds):
    """"""
    idx_list = []
    for i in range(len(bounds)):
        this_dim = bounds[i]
        lo,hi = this_dim[0],this_dim[1]   # bounds for this dimension
        this_dim_idxs = range(lo,hi+1)    # indexes for this dimension
        idx_list.append(this_dim_idxs)

    return idx2subs(idx_list)
1037570
def from_auto_dict(values, source='auto'):
    '''
    

    '''
    for name, value in values.items():
        values[name] = from_auto(name, value, source)

    return values
957685
def k_depth(d, depth, _counter=1):
        
        if depth == 0:
            yield d[_meta]["_rootname"]
        else:
            if _counter == depth:
                for key in DictTree.k(d):
                    yield key
            else:
                _counter += 1
                for node in DictTree.v(d):
                    for key in DictTree.k_depth(node, depth, _counter):
                        yield key
1165499
def Operate(self, values):
    """"""
    for val in values:
      try:
        if self.Operation(val, self.right_operand):
          return True
      except (TypeError, ValueError):
        pass

    return False