def extract_edges()

in uberpoet/dotreader.py [0:0]


    def extract_edges(self, text):
        # type: (str)-> List[List[str]]
        """
        Converts dot file text with buck targets as edges into a simpler [(string,string)] list.
        Also filters out unwanted target types based on the names in self.modules_filter.

        Dot files are basically lines of `"string" -> "string";` that represent a list of edges in a
        graph.
        """

        def edge(f_line):
            return f_line[:-1].split('->')

        def name(f_part):
            return str(f_part.strip().replace('"', ''))

        def fil(f_line):
            lower = line.lower()
            bad_word = False
            for k in self.modules_filter:
                if k in lower:
                    bad_word = True
                    break
            return '->' in f_line and not bad_word

        return [[name(part) for part in edge(line)] for line in text.splitlines() if fil(line)]