diff -r 31aaa11672d3 -r ab5678db972f src/eric7/Project/Project.py --- a/src/eric7/Project/Project.py Fri Dec 23 11:37:49 2022 +0100 +++ b/src/eric7/Project/Project.py Sat Dec 24 17:31:46 2022 +0100 @@ -2030,26 +2030,29 @@ self.__addSingleDirectory(filetype, source, target, True) ignore_patterns = [ + ".svn", + ".hg", + ".git", + ".ropeproject", + ".eric7project", + ".jedi", + "__pycache__", + ] + [ pattern for pattern, filetype in self.__pdata["FILETYPES"].items() if filetype == "__IGNORE__" ] - # TODO: replace os.listdir() with os.scandir() # now recurse into subdirectories - for name in os.listdir(source): - ns = os.path.join(source, name) - if os.path.isdir(ns): - skip = False - for ignore_pattern in ignore_patterns: - if fnmatch.fnmatch(name, ignore_pattern): - skip = True - break - if skip: - continue - - nt = os.path.join(target, name) - self.__addRecursiveDirectory(filetype, ns, nt) + with os.scandir(source) as dirEntriesIterator: + for dirEntry in dirEntriesIterator: + if dirEntry.is_dir() and not any( + fnmatch.fnmatch(dirEntry.name, ignore_pattern) + for ignore_pattern in ignore_patterns + ): + self.__addRecursiveDirectory( + filetype, dirEntry.path, os.path.join(target, dirEntry.name) + ) @pyqtSlot() def addDirectory(self, fileTypeFilter=None, startdir=None): @@ -6925,10 +6928,11 @@ """ with os.scandir(self.getProjectPath()) as ppathDirEntriesIterator: for dirEntry in ppathDirEntriesIterator: - if dirEntry.is_dir(): - # potential venv directory; check for 'pyvenv.cfg' - if os.path.exists(os.path.join(dirEntry.path, "pyvenv.cfg")): - return dirEntry.path + # potential venv directory; check for 'pyvenv.cfg' + if dirEntry.is_dir() and os.path.exists( + os.path.join(dirEntry.path, "pyvenv.cfg") + ): + return dirEntry.path # check for some common names in case 'pyvenv.cfg' is missing for venvPathName in (".venv", "venv", ".env", "env"):