def read_dot_file()

in uberpoet/dotreader.py [0:0]


    def read_dot_file(self, path, root_node_name, is_debug=False):
        # type: (str, str, bool) -> (ModuleNode, List[ModuleNode])
        """
        Reads a BUCK dependency dump in a dot/gv file at `path` and returns a `ModuleNode`
        graph root and list of nodes to generate a mock app from it.

        :param path:  Path to the dot file
        :param root_node_name:  The name of the root application node in the dependency graph
        :param is_debug: Enable this to dump some intermediate objects to help with debugging
        :return: The a tuple of the root node of the tree and a list of all nodes in the tree
        """
        with open(path, 'r') as f:
            text = f.read()

        raw_edges = self.extract_edges(text)
        ident_names = self.identical_names(raw_edges)
        edges = self.clean_edge_names(raw_edges)
        dep_map = self.make_dep_map_from_edges(edges)  # A dep_map is really an outgoing edge map

        # Debug dumps of dot reader state for debugging
        if is_debug:
            incoming_map = self.incoming_edge_map_from_dep_map(dep_map)
            anon_edge = self.anonymize_edge_names(edges, root_node_name)
            self.debug_dump([edges, raw_edges, anon_edge], [dep_map, ident_names, incoming_map])

        if ident_names:
            logging.error("Found identical buck target names in dot file: %s", path)
            logging.error(str(ident_names))
            raise ValueError("Dot file contains buck target names that are identical, but have different paths")
        else:
            root, nodes = self.mod_graph_from_dep_map(dep_map, root_node_name)
            logging.debug("%s %s total nodes: %d", root, root.deps, len(nodes))
            return root, nodes