Recursively walk the spec input tree.
485381
private static List<CardinalitySpec> createChildren( Map<String, Object> rawSpec ) {

        List<CardinalitySpec> children = new ArrayList<>();
        Set<String> actualKeys = new HashSet<>();

        for ( String keyString : rawSpec.keySet() ) {

            Object rawRhs = rawSpec.get( keyString );

            CardinalitySpec childSpec;
            if ( rawRhs instanceof Map ) {
                childSpec = new CardinalityCompositeSpec( keyString, (Map<String, Object>) rawRhs );
            } else {
                childSpec = new CardinalityLeafSpec( keyString, rawRhs );
            }

            String childCanonicalString = childSpec.pathElement.getCanonicalForm();

            if ( actualKeys.contains( childCanonicalString ) ) {
                throw new IllegalArgumentException( "Duplicate canonical CardinalityTransform key found : " + childCanonicalString );
            }

            actualKeys.add( childCanonicalString );

            children.add( childSpec );
        }

        return children;
    }
1143547
def spec(self):
        """"""
        return dict(
            headers=self.header_lines,
            start=self.start_line,
            comments=self.comment_lines,
            end=self.end_line
        )
1250593
def walk_sequence(fexp, ftree, tree)

      i = fexp.child_ids.first

      ehead = ftree[2].take(i)
      ecurrent = ftree[2][i]
      etail = ftree[2].drop(i + 1)
      head = tree[2].take(i)
      current = tree[2][i]
      tail = tree[2].drop(i + 1)

      if ehead != head
        #
        # if the name and/or attributes of the exp are supposed to change
        # then we have to reapply it
        #
        register(MutationPoint.new(fexp.fei, tree, :re_apply))
        return
      end

      if ecurrent != current
        #
        # if the child currently applied is supposed to change, let's walk
        # it down
        #
        walk(@ps.fexp(fexp.children.first), current)
      end

      #if etail != tail
      #  #
      #  # if elements are added at the end of the sequence, let's register
      #  # a mutation that simply changes the tree (no need to re-apply)
      #  #
      #  register(MutationPoint.new(fexp.fei, tree, :update))
      #end
    end
1177206
def _walk_breadth(
        self,
        fs,  # type: FS
        path,  # type: Text
        namespaces=None,  # type: Optional[Collection[Text]]
    ):
        # type: (...) -> Iterator[Tuple[Text, Optional[Info]]]
        
        queue = deque([path])
        push = queue.appendleft
        pop = queue.pop

        _combine = combine
        _scan = self._scan
        _calculate_depth = self._calculate_depth
        _check_open_dir = self._check_open_dir
        _check_scan_dir = self._check_scan_dir
        _check_file = self.check_file

        depth = _calculate_depth(path)

        while queue:
            dir_path = pop()
            for info in _scan(fs, dir_path, namespaces=namespaces):
                if info.is_dir:
                    _depth = _calculate_depth(dir_path) - depth + 1
                    if _check_open_dir(fs, dir_path, info):
                        yield dir_path, info  # Opened a directory
                        if _check_scan_dir(fs, dir_path, info, _depth):
                            push(_combine(dir_path, info.name))
                else:
                    if _check_file(fs, info):
                        yield dir_path, info  # Found a file
            yield dir_path, None
484176
def parse_spec(self, spec):
    

    if spec.endswith('::'):
      spec_path = spec[:-len('::')]
      return DescendantAddresses(self._normalize_spec_path(spec_path))
    elif spec.endswith(':'):
      spec_path = spec[:-len(':')]
      return SiblingAddresses(self._normalize_spec_path(spec_path))
    else:
      spec_parts = spec.rsplit(':', 1)
      spec_path = self._normalize_spec_path(spec_parts[0]) 
      name = spec_parts[1] if len(spec_parts) > 1 else os.path.basename(spec_path)
      return SingleAddress(spec_path, name)
591244
private void findPath(Map<Spec, SpecExecutor> specExecutorInstanceMap, Spec spec) {
    inMemoryWeightGraphGenerator();
    FlowSpec flowSpec = (FlowSpec) spec;
    if (optionalUserSpecifiedPath.isPresent()) {
      log.info("Starting to evaluate user's specified path ... ");
      if (userSpecifiedPathVerificator(specExecutorInstanceMap, flowSpec)) {
        log.info("User specified path[ " + optionalUserSpecifiedPath.get() + "] successfully verified.");
        return;
      } else {
        log.error("Will not execute user specified path[ " + optionalUserSpecifiedPath.get() + "]");
        log.info("Start to execute FlowCompiler's algorithm for valid data movement path");
      }
    }

    ServiceNode sourceNode =
        new BaseServiceNodeImpl(flowSpec.getConfig().getString(ServiceConfigKeys.FLOW_SOURCE_IDENTIFIER_KEY));

    ServiceNode targetNode =
        new BaseServiceNodeImpl(flowSpec.getConfig().getString(ServiceConfigKeys.FLOW_DESTINATION_IDENTIFIER_KEY));

    List<FlowEdge> resultEdgePath = dijkstraBasedPathFindingHelper(sourceNode, targetNode, this.weightedGraph);
    for (int i = 0; i < resultEdgePath.size() ; i++) {
      FlowEdge tmpFlowEdge = resultEdgePath.get(i);
      ServiceNode edgeSrcNode = ((LoadBasedFlowEdgeImpl) tmpFlowEdge).getSourceNode();
      ServiceNode edgeTgtNode = ((LoadBasedFlowEdgeImpl) tmpFlowEdge).getTargetNode();
      specExecutorInstanceMap.put(convertHopToJobSpec(edgeSrcNode, edgeTgtNode, flowSpec),
          ((LoadBasedFlowEdgeImpl) (resultEdgePath.get(i))).getSpecExecutorInstance());
    }
  }
997782
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.')
1109040
def canonicalize_spec(spec, parent_context):
  """"""

  test_specs = {k:v for (k,v) in spec.items() if k.startswith("Test")}
  local_context = {k:v for (k,v) in spec.items() if not k.startswith("Test")}

  context = reduce_contexts(parent_context, local_context)

  if test_specs:
    return {k: canonicalize_spec(v, context) for (k,v) in test_specs.items()}
  else:
    program_chunks = sum([resolve_module(m,context['Definitions']) for m in context['Modules']],[]) + [context['Program']]
    test_spec = {
      'Arguments': context['Arguments'],
      'Program': "\n".join(program_chunks),
      'Expect': context['Expect'],
    }
    return test_spec
881646
def _permute_core_specs(self):
        """"""
        obj_trees = []
        projects = self._get_requested_spec(self._obj_lib, _PROJECTS_STR)
        for project in projects:
            models = self._get_requested_spec(project, _MODELS_STR)
            for model in models:
                runs = self._get_requested_spec(model, _RUNS_STR)
                for run in runs:
                    obj_trees.append({
                        self._NAMES_SUITE_TO_CALC[_PROJECTS_STR]: project,
                        self._NAMES_SUITE_TO_CALC[_MODELS_STR]: model,
                        self._NAMES_SUITE_TO_CALC[_RUNS_STR]: run,
                    })
        return obj_trees
738597
def _iter_walk(
        self,
        fs,  # type: FS
        path,  # type: Text
        namespaces=None,  # type: Optional[Collection[Text]]
    ):
        # type: (...) -> Iterator[Tuple[Text, Optional[Info]]]
        """"""
        if self.search == "breadth":
            return self._walk_breadth(fs, path, namespaces=namespaces)
        else:
            return self._walk_depth(fs, path, namespaces=namespaces)
1007590
def scantree(path: str) -> Generator:
    """"""
    for entry in os.scandir(path):
        if entry.is_dir(follow_symlinks=False):
            yield from scantree(entry.path)
        else:
            if entry.name.endswith('.py'):
                yield entry
952754
def _walk(self):
        """"""

        self._base_len = len(self.base)

        for base, dirs, files in os.walk(self.base, followlinks=self.follow_links):
            # Remove child folders based on exclude rules
            for name in dirs[:]:
                try:
                    if not self._valid_folder(base, name):
                        dirs.remove(name)
                except Exception:
                    dirs.remove(name)
                    value = self.on_error(base, name)
                    if value is not None:  # pragma: no cover
                        yield value

                if self._abort:
                    break

            # Search files if they were found
            if len(files):
                # Only search files that are in the include rules
                for name in files:
                    try:
                        valid = self._valid_file(base, name)
                    except Exception:
                        valid = False
                        value = self.on_error(base, name)
                        if value is not None:
                            yield value

                    if valid:
                        yield self.on_match(base, name)
                    else:
                        self._skipped += 1
                        value = self.on_skip(base, name)
                        if value is not None:
                            yield value

                    if self._abort:
                        break

            if self._abort:
                break
1284615
def walk(self):
        """"""
        yield self
        if self.has_arguments():
            for arg in self.args_definition:
                if not arg["name"] in self.arguments:
                    continue
                value = self.arguments[arg["name"]]
                if type(value) == list:
                    if self.__get_arg_type(arg["name"]) == ["testlist"]:
                        for t in value:
                            for node in t.walk():
                                yield node
                if isinstance(value, Command):
                    for node in value.walk():
                        yield node
        for ch in self.children:
            for node in ch.walk():
                yield node
830621
def _recurse(coreml_tree, scikit_tree, tree_id, node_id, scaling = 1.0, mode = 'regressor',
             n_classes = 2, tree_index = 0):
    
    if not(HAS_SKLEARN):
        raise RuntimeError('scikit-learn not found. scikit-learn conversion API is disabled.')

    ## Recursion should not be called on the leaf node.
    if node_id == _tree.TREE_LEAF:
        raise ValueError("Invalid node_id %s" % _tree.TREE_LEAF)

    # Add a branch node to the tree
    if scikit_tree.children_left[node_id] != _tree.TREE_LEAF:
        branch_mode = 'BranchOnValueLessThanEqual'
        feature_index = scikit_tree.feature[node_id]
        feature_value = scikit_tree.threshold[node_id]
        left_child_id = scikit_tree.children_left[node_id]
        right_child_id = scikit_tree.children_right[node_id]

        # Add a branch node
        coreml_tree.add_branch_node(tree_id, node_id, feature_index,
                feature_value, branch_mode, left_child_id, right_child_id)

        # Now recurse
        _recurse(coreml_tree, scikit_tree, tree_id, left_child_id, scaling, mode, n_classes, tree_index)
        _recurse(coreml_tree, scikit_tree, tree_id, right_child_id, scaling, mode, n_classes, tree_index)

    # Add a leaf node to the tree
    else:
        # Get the scikit-learn value
        if scikit_tree.n_outputs != 1:
            raise ValueError('Expected only 1 output in the scikit-learn tree.')
        value = _get_value(scikit_tree.value[node_id], mode, scaling, n_classes, tree_index)
        coreml_tree.add_leaf_node(tree_id, node_id, value)
236231
def walk(self, cli):
        
        yield self
        for c in self.children:
            for i in c.walk(cli):
                yield i
272031
private void traverse(GroovySourceAST t) {
        if (t == null) { return; }
        if (unvisitedNodes != null) {
           unvisitedNodes.add(t);
        }
        GroovySourceAST child = (GroovySourceAST)t.getFirstChild();
        if (child != null) {
            traverse(child);
        }
        GroovySourceAST sibling = (GroovySourceAST)t.getNextSibling();
        if (sibling != null) {
            traverse(sibling);
        }
    }
523501
private WalkingAction walk(N tree, TreeVisitor<N> walkerClient) {
	WalkingAction action = walkerClient.visit(tree);
	if (action == WalkingAction.ABORT) {
	    return WalkingAction.ABORT;
	} else if (action == WalkingAction.LEAVE_BRANCH) {
	    return WalkingAction.PROCEED;
	}
	for (N child : tree.getChildren()) {
	    if (walk(child, walkerClient) == WalkingAction.ABORT) {
		return WalkingAction.ABORT;
	    }
	}
	return WalkingAction.PROCEED;
    }