Jelajahi Sumber

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
rdb 5 tahun lalu
induk
melakukan
86937c7bb9
1 mengubah file dengan 24 tambahan dan 0 penghapusan
  1. 24 0
      direct/src/dist/commands.py

+ 24 - 0
direct/src/dist/commands.py

@@ -983,6 +983,26 @@ class build_apps(setuptools.Command):
             return check_pattern(fname, include_copy_list) and \
             return check_pattern(fname, include_copy_list) and \
                 not check_pattern(fname, ignore_copy_list)
                 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):
         def copy_file(src, dst):
             src = os.path.normpath(src)
             src = os.path.normpath(src)
             dst = os.path.normpath(dst)
             dst = os.path.normpath(dst)
@@ -1023,6 +1043,10 @@ class build_apps(setuptools.Command):
         rootdir = os.getcwd()
         rootdir = os.getcwd()
         for dirname, subdirlist, filelist in os.walk(rootdir):
         for dirname, subdirlist, filelist in os.walk(rootdir):
             dirpath = os.path.relpath(dirname, rootdir)
             dirpath = os.path.relpath(dirname, rootdir)
+            if skip_directory(dirpath):
+                self.announce('skipping directory {}'.format(dirpath))
+                continue
+
             for fname in filelist:
             for fname in filelist:
                 src = os.path.join(dirpath, fname)
                 src = os.path.join(dirpath, fname)
                 dst = os.path.join(builddir, update_path(src))
                 dst = os.path.join(builddir, update_path(src))