BAT Pack can now exclude files based on glob patterns

This commit is contained in:
Sybren A. Stüvel
2018-03-14 16:06:21 +01:00
parent 0e9de7753c
commit 8340df129d
3 changed files with 53 additions and 10 deletions
+10
View File
@@ -62,6 +62,8 @@ class Packer:
self.target = target
self.noop = noop
self._exclude_globs = set() # type: typing.Set[str]
from blender_asset_tracer.cli import common
self._shorten = functools.partial(common.shorten, self.project)
@@ -89,6 +91,10 @@ class Packer:
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
self.close()
def exclude(self, *globs: str):
"""Register glob-compatible patterns of files that should be ignored."""
self._exclude_globs.update(globs)
def strategise(self) -> None:
"""Determine what to do with the assets.
@@ -112,6 +118,10 @@ class Packer:
# blendfile thing, since different blendfiles can refer to it in
# different ways (for example with relative and absolute paths).
asset_path = usage.abspath
if any(asset_path.match(glob) for glob in self._exclude_globs):
log.info('Excluding file: %s', asset_path)
continue
if not asset_path.exists():
log.info('Missing file: %s', asset_path)
self.missing_files.add(asset_path)