Skip to content

Commit a554409

Browse files
committed
[processing] don't use scandir() to get directory contents (fix #18180)
1 parent 35cc4c9 commit a554409

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

python/plugins/processing/script/ScriptAlgorithmProvider.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@ def loadAlgorithms(self):
9999
self.algs = []
100100
folders = ScriptUtils.scriptsFolders()
101101
for folder in folders:
102-
items = os.scandir(folder)
102+
items = [f for f in os.listdir(folder) if os.path.isfile(os.path.join(folder, f))]
103+
#items = os.scandir(folder)
103104
for entry in items:
104-
if entry.name.lower().endswith(".py") and entry.is_file():
105-
moduleName = os.path.splitext(entry.name)[0]
106-
filePath = os.path.abspath(os.path.join(folder, entry.name))
105+
if entry.lower().endswith(".py"):
106+
#if entry.name.lower().endswith(".py") and entry.is_file():
107+
#moduleName = os.path.splitext(entry.name)[0]
108+
moduleName = os.path.splitext(os.path.basename(entry))[0]
109+
filePath = os.path.abspath(os.path.join(folder, entry))
107110
alg = ScriptUtils.loadAlgorithm(moduleName, filePath)
108111
if alg is not None:
109112
self.algs.append(alg)

0 commit comments

Comments
 (0)