diff --git a/blender_asset_tracer/tracer/__init__.py b/blender_asset_tracer/tracer/__init__.py index a5f84d5..5fe8444 100644 --- a/blender_asset_tracer/tracer/__init__.py +++ b/blender_asset_tracer/tracer/__init__.py @@ -8,7 +8,6 @@ from . import result, block_walkers log = logging.getLogger(__name__) codes_to_skip = { - b'LI', # Library blocks we handle after the blend file itself. b'ID', b'WM', b'SN', # These blocks never have external assets. } diff --git a/blender_asset_tracer/tracer/block_walkers.py b/blender_asset_tracer/tracer/block_walkers.py index 1f73cf2..32c2e00 100644 --- a/blender_asset_tracer/tracer/block_walkers.py +++ b/blender_asset_tracer/tracer/block_walkers.py @@ -69,6 +69,16 @@ def _from_block_im(block: blendfile.BlendFileBlock) -> typing.Iterator[result.Bl yield result.BlockUsage(block, pathname, is_sequence, path_full_field=field) +def _from_block_li(block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]: + """Library data blocks.""" + path, field = block.get(b'name', return_field=True) + yield result.BlockUsage(block, path, path_full_field=field) + + # The 'filepath' also points to the blend file. However, this is set to the + # absolute path of the file by Blender (see BKE_library_filepath_set). This + # is thus not a property we have to report or rewrite. + + def _from_block_me(block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]: """Mesh data blocks.""" block_external = block.get_pointer((b'ldata', b'external'), None) diff --git a/tests/blendfiles/linked_cube.blend b/tests/blendfiles/linked_cube.blend index 77a0b28..e7baf3d 100644 Binary files a/tests/blendfiles/linked_cube.blend and b/tests/blendfiles/linked_cube.blend differ diff --git a/tests/test_tracer.py b/tests/test_tracer.py index f082714..d638ebc 100644 --- a/tests/test_tracer.py +++ b/tests/test_tracer.py @@ -76,9 +76,11 @@ class DepsTest(AbstractTracerTest): if exp.basename_field is not None: self.assertEqual(exp.basename_field, dep.path_base_field.name.name_full.decode()) - del expects[dep.block_name] # should be seen only once + # Each expectation should be seen only once. + del expects[dep.block_name] + # All expected uses should have been seen. - self.assertEqual({}, expects) + self.assertEqual({}, expects, 'Expected results were not seen.') def test_no_deps(self): self.assert_deps('basic_file.blend', {}) @@ -154,3 +156,8 @@ class DepsTest(AbstractTracerTest): b'VFHack-Bold': Expect('VFont', 'name[1024]', None, None, b'/usr/share/fonts/truetype/hack/Hack-Bold.ttf', False), }) + + def test_block_li(self): + self.assert_deps('linked_cube.blend', { + b'LILib': Expect('Library', 'name[1024]', None, None, b'//basic_file.blend', False), + })