[processing] don't use scandir() to get directory contents (fix #18180)

This commit is contained in:
Alexander Bruy 2018-02-23 10:28:53 +02:00
parent 35cc4c902d
commit a554409ede

View File

@ -99,11 +99,14 @@ class ScriptAlgorithmProvider(QgsProcessingProvider):
self.algs = []
folders = ScriptUtils.scriptsFolders()
for folder in folders:
items = os.scandir(folder)
items = [f for f in os.listdir(folder) if os.path.isfile(os.path.join(folder, f))]
#items = os.scandir(folder)
for entry in items:
if entry.name.lower().endswith(".py") and entry.is_file():
moduleName = os.path.splitext(entry.name)[0]
filePath = os.path.abspath(os.path.join(folder, entry.name))
if entry.lower().endswith(".py"):
#if entry.name.lower().endswith(".py") and entry.is_file():
#moduleName = os.path.splitext(entry.name)[0]
moduleName = os.path.splitext(os.path.basename(entry))[0]
filePath = os.path.abspath(os.path.join(folder, entry))
alg = ScriptUtils.loadAlgorithm(moduleName, filePath)
if alg is not None:
self.algs.append(alg)