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
This commit is contained in:
rdb 2020-12-24 14:17:20 +01:00
parent adbeea33fb
commit 86937c7bb9

View File

@ -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))