Packer: store the output path of the blend file in the target directory

This allows the Flamenco Add-on to get the final path of the blend file.
This commit is contained in:
Sybren A. Stüvel 2018-03-14 15:19:35 +01:00
parent 73b264f6bc
commit 6b51183095
2 changed files with 17 additions and 0 deletions

View File

@ -74,6 +74,7 @@ class Packer:
self._actions = collections.defaultdict(AssetAction) \
# type: typing.DefaultDict[pathlib.Path, AssetAction]
self.missing_files = set() # type: typing.Set[pathlib.Path]
self._output_path = None # type: pathlib.Path
# Number of files we would copy, if not for --noop
self._file_count = 0
@ -91,6 +92,11 @@ class Packer:
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
self.close()
@property
def output_path(self) -> pathlib.Path:
"""The path of the packed blend file in the target directory."""
return self._output_path
def exclude(self, *globs: str):
"""Register glob-compatible patterns of files that should be ignored."""
self._exclude_globs.update(globs)
@ -107,6 +113,7 @@ class Packer:
# we have to explicitly add it to the _packed_paths.
bfile_path = self.blendfile.absolute()
bfile_pp = self.target / bfile_path.relative_to(self.project)
self._output_path = bfile_pp
act = self._actions[bfile_path]
act.path_action = PathAction.KEEP_PATH

View File

@ -239,3 +239,13 @@ class PackTest(AbstractPackTest):
[self.blendfiles / 'textures/HDRI/Myanmar/Golden Palace 2, Old Bagan-1k.exr'],
list(packer.missing_files)
)
def test_output_path(self):
infile = self.blendfiles / 'basic_file.blend'
packer = pack.Packer(infile, self.blendfiles.parent, self.tpath)
packer.strategise()
self.assertEqual(
self.tpath / self.blendfiles.name / infile.name,
packer.output_path
)