Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
feat: fnmatchcase on local paths of persistent and ignored file patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
joelgomes1994 committed Apr 3, 2022
1 parent 9359be1 commit 10e3a75
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
6 changes: 4 additions & 2 deletions release/scripts/build_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
17 changes: 12 additions & 5 deletions source/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 10e3a75

Please sign in to comment.