From 8709725988387c6184717f345acfea9e3b2db3fd Mon Sep 17 00:00:00 2001 From: relikd Date: Wed, 10 Sep 2025 01:15:43 +0200 Subject: [PATCH] ref: File.recursiveFiles --- brew.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/brew.py b/brew.py index 3aae54f..0b2735d 100755 --- a/brew.py +++ b/brew.py @@ -1920,20 +1920,18 @@ class InstallQueue: class Fixer: @staticmethod def run(path: str) -> None: - for base, dirs, files in os.walk(path): - for file in files: - fname = os.path.join(base, file) - if os.path.islink(fname): - Fixer.symlink(fname) - continue + for fname in File.recursiveFiles(path): + if os.path.islink(fname): + Fixer.symlink(fname) + continue - if File.isMachO(fname): - Dylib(fname).fix() - elif File.isBinary(fname): - pass # skip other binary (.a, .class, .png, ...) - else: - # replace all @@homebrew@@ placeholders - Fixer.inreplace(fname) + if File.isMachO(fname): + Dylib(fname).fix() + elif File.isBinary(fname): + pass # skip other binary (.a, .class, .png, ...) + else: + # replace all @@homebrew@@ placeholders + Fixer.inreplace(fname) @staticmethod def symlink(fname: str) -> None: @@ -2698,6 +2696,15 @@ class File: with open(fname, 'a'): os.utime(fname, None) + @staticmethod + def recursiveFiles(path: str) -> Iterator[str]: + ''' yield only files from `os.walk(path)` ''' + if os.path.isdir(path): + for base, _, files in os.walk(path): + for file in files: + if file != '.DS_Store': + yield os.path.join(base, file) + @staticmethod def folderSize(path: str) -> tuple[int, int]: '''Calculate total size of folder and all it's content (recursively)'''