Пример #1
0
    def all_roots(self):
        """Return all known source roots.

        Returns a generator over (source root, list of langs, category) triples.

        Note: Requires a directory walk to match actual directories against patterns.
        However we don't descend into source roots, once found, so this should be fast in practice.
        Note: Does not follow symlinks.
        """
        project_tree = FileSystemProjectTree(get_buildroot(),
                                             self._options.pants_ignore)

        fixed_roots = set()
        for root, langs, category in self._trie.fixed():
            if project_tree.exists(root):
                yield self._source_root_factory.create(root, langs, category)
            fixed_roots.add(root)

        for relpath, dirnames, _ in project_tree.walk("", topdown=True):
            match = self._trie.find(relpath)
            if match:
                if not any(
                        fixed_root.startswith(relpath)
                        for fixed_root in fixed_roots):
                    yield match  # Found a source root not a prefix of any fixed roots.
                del dirnames[:]  # Don't continue to walk into it.