Path rewriting when packing.

Doesn't work with sequences, nor with split dirname/basename fields.
This commit is contained in:
Sybren A. Stüvel
2018-03-06 16:06:36 +01:00
parent 433ad8f16a
commit 71dd5bc11b
9 changed files with 285 additions and 38 deletions
Binary file not shown.
+27
View File
@@ -1,3 +1,4 @@
from pathlib import Path
import unittest
from blender_asset_tracer.bpathlib import BlendPath
@@ -52,3 +53,29 @@ class BlendPathTest(unittest.TestCase):
self.assertEqual(b'/root/and/parent.blend', b'/root/and' / BlendPath(b'parent.blend'))
with self.assertRaises(ValueError):
b'/root/and' / BlendPath(b'/parent.blend')
def test_mkrelative(self):
self.assertEqual(b'//asset.png', BlendPath.mkrelative(
Path('/path/to/asset.png'),
Path('/path/to/bfile.blend'),
))
self.assertEqual(b'//to/asset.png', BlendPath.mkrelative(
Path('/path/to/asset.png'),
Path('/path/bfile.blend'),
))
self.assertEqual(b'//../of/asset.png', BlendPath.mkrelative(
Path('/path/of/asset.png'),
Path('/path/to/bfile.blend'),
))
self.assertEqual(b'//../../path/of/asset.png', BlendPath.mkrelative(
Path('/path/of/asset.png'),
Path('/some/weird/bfile.blend'),
))
self.assertEqual(b'//very/very/very/very/very/deep/asset.png', BlendPath.mkrelative(
Path('/path/to/very/very/very/very/very/deep/asset.png'),
Path('/path/to/bfile.blend'),
))
self.assertEqual(b'//../../../../../../../../shallow/asset.png', BlendPath.mkrelative(
Path('/shallow/asset.png'),
Path('/path/to/very/very/very/very/very/deep/bfile.blend'),
))
+8
View File
@@ -212,6 +212,14 @@ class DepsTest(AbstractTracerTest):
# b'//textures/Textures/Buildings/buildings_roof_04-color.png', False),
})
def test_usage_abspath(self):
deps = [dep for dep in tracer.deps(self.blendfiles / 'doubly_linked.blend')
if dep.asset_path == b'//material_textures.blend']
usage = deps[0]
expect = self.blendfiles / 'material_textures.blend'
self.assertEqual(expect, usage.abspath)
def test_sim_data(self):
self.assert_deps('T53562/bam_pack_bug.blend', {
b'OBEmitter.modifiers[0]': Expect(