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:
parent
73b264f6bc
commit
6b51183095
@ -74,6 +74,7 @@ class Packer:
|
|||||||
self._actions = collections.defaultdict(AssetAction) \
|
self._actions = collections.defaultdict(AssetAction) \
|
||||||
# type: typing.DefaultDict[pathlib.Path, AssetAction]
|
# type: typing.DefaultDict[pathlib.Path, AssetAction]
|
||||||
self.missing_files = set() # type: typing.Set[pathlib.Path]
|
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
|
# Number of files we would copy, if not for --noop
|
||||||
self._file_count = 0
|
self._file_count = 0
|
||||||
@ -91,6 +92,11 @@ class Packer:
|
|||||||
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
|
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
|
||||||
self.close()
|
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):
|
def exclude(self, *globs: str):
|
||||||
"""Register glob-compatible patterns of files that should be ignored."""
|
"""Register glob-compatible patterns of files that should be ignored."""
|
||||||
self._exclude_globs.update(globs)
|
self._exclude_globs.update(globs)
|
||||||
@ -107,6 +113,7 @@ class Packer:
|
|||||||
# we have to explicitly add it to the _packed_paths.
|
# we have to explicitly add it to the _packed_paths.
|
||||||
bfile_path = self.blendfile.absolute()
|
bfile_path = self.blendfile.absolute()
|
||||||
bfile_pp = self.target / bfile_path.relative_to(self.project)
|
bfile_pp = self.target / bfile_path.relative_to(self.project)
|
||||||
|
self._output_path = bfile_pp
|
||||||
|
|
||||||
act = self._actions[bfile_path]
|
act = self._actions[bfile_path]
|
||||||
act.path_action = PathAction.KEEP_PATH
|
act.path_action = PathAction.KEEP_PATH
|
||||||
|
|||||||
@ -239,3 +239,13 @@ class PackTest(AbstractPackTest):
|
|||||||
[self.blendfiles / 'textures/HDRI/Myanmar/Golden Palace 2, Old Bagan-1k.exr'],
|
[self.blendfiles / 'textures/HDRI/Myanmar/Golden Palace 2, Old Bagan-1k.exr'],
|
||||||
list(packer.missing_files)
|
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
|
||||||
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user