Example #1
0
    def find_excluded_files(self):  # type: () -> Set[str]
        # Checking VCS
        vcs = get_vcs(self._original_path)
        if not vcs:
            vcs_ignored_files = set()
        else:
            vcs_ignored_files = set(vcs.get_ignored_files())

        explicitely_excluded = set()
        for excluded_glob in self._package.exclude:

            for excluded in glob(
                Path(self._path, excluded_glob).as_posix(), recursive=True
            ):
                explicitely_excluded.add(
                    Path(excluded).relative_to(self._path).as_posix()
                )

        ignored = vcs_ignored_files | explicitely_excluded
        result = set()
        for file in ignored:
            result.add(file)

        # The list of excluded files might be big and we will do a lot
        # containment check (x in excluded).
        # Returning a set make those tests much much faster.
        return result
Example #2
0
    def find_excluded_files(self):  # type: () -> Set[str]
        # Checking VCS
        vcs = get_vcs(self._path)
        if not vcs:
            vcs_ignored_files = set()
        else:
            vcs_ignored_files = set(vcs.get_ignored_files())

        explicitely_excluded = set()
        for excluded_glob in self._package.exclude:
            excluded_path = Path(self._path, excluded_glob)

            try:
                is_dir = excluded_path.is_dir()
            except OSError:
                # On Windows, testing if a path with a glob is a directory will raise an OSError
                is_dir = False
            if is_dir:
                excluded_glob = Path(excluded_glob, "**/*")

            for excluded in glob(Path(self._path, excluded_glob).as_posix(),
                                 recursive=True):
                explicitely_excluded.add(
                    Path(excluded).relative_to(self._path).as_posix())

        ignored = vcs_ignored_files | explicitely_excluded
        result = set()
        for file in ignored:
            result.add(file)

        # The list of excluded files might be big and we will do a lot
        # containment check (x in excluded).
        # Returning a set make those tests much much faster.
        return result