Allow Packer to be used as context manager + test for rewriting img seqs
This commit is contained in:
parent
d2ac0fa919
commit
0e9de7753c
@ -83,6 +83,12 @@ class Packer:
|
||||
"""Clean up any temporary files."""
|
||||
self._tmpdir.cleanup()
|
||||
|
||||
def __enter__(self) -> 'Packer':
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
|
||||
self.close()
|
||||
|
||||
def strategise(self) -> None:
|
||||
"""Determine what to do with the assets.
|
||||
|
||||
|
||||
BIN
tests/blendfiles/subdir/image_sequence_dir_up.blend
Normal file
BIN
tests/blendfiles/subdir/image_sequence_dir_up.blend
Normal file
Binary file not shown.
@ -184,7 +184,6 @@ class PointerTest(AbstractBlendFileTest):
|
||||
|
||||
seq = ed.get_pointer((b'seqbase', b'first'))
|
||||
|
||||
# This is very clear to me:
|
||||
seq.refine_type(b'Sequence')
|
||||
self.assertEqual(b'SQBlack', seq[b'name'])
|
||||
self.assertEqual(28, seq[b'type'])
|
||||
|
||||
@ -167,6 +167,27 @@ class PackTest(AbstractPackTest):
|
||||
|
||||
return infile, packer
|
||||
|
||||
def test_rewrite_sequence(self):
|
||||
ppath = self.blendfiles / 'subdir'
|
||||
infile = ppath / 'image_sequence_dir_up.blend'
|
||||
|
||||
with pack.Packer(infile, ppath, self.tpath) as packer:
|
||||
packer.strategise()
|
||||
packer.execute()
|
||||
|
||||
bf = blendfile.open_cached(self.tpath / infile.name, assert_cached=False)
|
||||
scene = bf.code_index[b'SC'][0]
|
||||
ed = scene.get_pointer(b'ed')
|
||||
seq = ed.get_pointer((b'seqbase', b'first'))
|
||||
seq_strip = seq.get_pointer(b'strip')
|
||||
|
||||
as_bytes = str((self.blendfiles / 'imgseq').absolute()).encode()
|
||||
relpath = b'//_outside_project%b' % as_bytes
|
||||
|
||||
# The image sequence base path should be rewritten.
|
||||
self.assertEqual(b'SQ000210.png', seq[b'name'])
|
||||
self.assertEqual(relpath, seq_strip[b'dir'])
|
||||
|
||||
def test_noop(self):
|
||||
ppath = self.blendfiles / 'subdir'
|
||||
infile = ppath / 'doubly_linked_up.blend'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user