From 86937c7bb952589472e2a579583f06f07545a7af Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 Dec 2020 14:17:20 +0100 Subject: [PATCH] dist: Check if entire directory should be skipped This is functionally equivalent, but reduces the message spam in verbose mode, and perhaps is a little faster --- direct/src/dist/commands.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index c84d453bfd..26f33a3e07 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -983,6 +983,26 @@ class build_apps(setuptools.Command): return check_pattern(fname, include_copy_list) and \ not check_pattern(fname, ignore_copy_list) + def skip_directory(src): + # Provides a quick-out for directory checks. NOT recursive. + fn = p3d.Filename.from_os_specific(os.path.normpath(src)) + path = fn.get_fullpath() + fn.make_absolute() + abspath = fn.get_fullpath() + + for pattern in ignore_copy_list: + if not pattern.pattern.endswith('/*') and \ + not pattern.pattern.endswith('/**'): + continue + + if abspath.startswith(pattern_dir + '/'): + return True + + if path.startswith(pattern_dir + '/'): + return True + + return False + def copy_file(src, dst): src = os.path.normpath(src) dst = os.path.normpath(dst) @@ -1023,6 +1043,10 @@ class build_apps(setuptools.Command): rootdir = os.getcwd() for dirname, subdirlist, filelist in os.walk(rootdir): dirpath = os.path.relpath(dirname, rootdir) + if skip_directory(dirpath): + self.announce('skipping directory {}'.format(dirpath)) + continue + for fname in filelist: src = os.path.join(dirpath, fname) dst = os.path.join(builddir, update_path(src))