From 10e3a75ba0367db65024e6b8462ef8af11312fa8 Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 3 Apr 2022 18:24:32 -0300 Subject: [PATCH] feat: fnmatchcase on local paths of persistent and ignored file patterns --- release/scripts/build_data.py | 6 ++++-- source/launcher.py | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/release/scripts/build_data.py b/release/scripts/build_data.py index c083676..ef412cc 100644 --- a/release/scripts/build_data.py +++ b/release/scripts/build_data.py @@ -47,12 +47,14 @@ def _compressDataFile(data, sourcePath, dataFile): for _file in glob.glob(sourcePath.as_posix() + "/**", recursive=True): _file = _Path(_file).resolve() ignore = False - isScriptIgnored = _file.suffix == ".py" and compileScripts + isIgnoredScript = _file.suffix == ".py" and compileScripts isCompiledScript = _file.suffix == ".pyc" and compileScripts if not isCompiledScript and "Ignore" in data.keys(): + pathToMatch = _file.as_posix().replace(sourcePath.as_posix(), "") + for pattern in data["Ignore"]: - if isScriptIgnored or fnmatchcase(_file.name, pattern): + if isIgnoredScript or fnmatchcase(pathToMatch, pattern): ignore = True if _file.is_file(): print(" - Ignored", _file.relative_to(sourcePath)) diff --git a/source/launcher.py b/source/launcher.py index ba19ffa..5012114 100644 --- a/source/launcher.py +++ b/source/launcher.py @@ -219,14 +219,21 @@ def getFilesLists(path): # type: (Path) -> list[list[Path]] import glob + import os + from fnmatch import fnmatchcase - persistentFiles = [] - generalFiles = [] + persistentFiles = [] # type: list[Path] + generalFiles = [] # type: list[Path] # Populate persistent files list - for pattern in config["Persistent"]: - persistentFiles += [Path(p).resolve() for p in glob.glob( - path.as_posix() + "/**/" + pattern, recursive=True)] + for _folder, _subfolders, _files in os.walk(path.as_posix()): + for _file in _files: + _file = Path(_folder) / _file + pathToMatch = _file.as_posix().replace(path.as_posix(), "") + + for pattern in config["Persistent"]: + if fnmatchcase(pathToMatch, pattern): + persistentFiles.append(_file.resolve()) # Populate general files list generalFiles += [Path(p).resolve() for p in glob.glob(