Removed Packer._packed_paths

The info in that dict is also available in Packer._actions[...].new_path
This commit is contained in:
Sybren A. Stüvel 2018-03-08 11:15:38 +01:00
parent 8fc1072144
commit b5418e1f5f
2 changed files with 6 additions and 19 deletions

View File

@ -45,7 +45,6 @@ class Packer:
# Filled by strategise() # Filled by strategise()
self._actions = collections.defaultdict(AssetAction) self._actions = collections.defaultdict(AssetAction)
self._rewrites = collections.defaultdict(list) self._rewrites = collections.defaultdict(list)
self._packed_paths = {} # from path in project to path in BAT Pack dir.
self._copy_cache_miss = self._copy_cache_hit = 0 self._copy_cache_miss = self._copy_cache_hit = 0
@ -64,7 +63,7 @@ class Packer:
act = self._actions[bfile_path] act = self._actions[bfile_path]
act.path_action = PathAction.KEEP_PATH act.path_action = PathAction.KEEP_PATH
act.new_path = self._packed_paths[bfile_path] = bfile_pp act.new_path = bfile_pp
new_location_paths = set() new_location_paths = set()
for usage in tracer.deps(self.blendfile): for usage in tracer.deps(self.blendfile):
@ -89,7 +88,7 @@ class Packer:
else: else:
log.info('%s can keep using %s', bfile_path, usage.asset_path) log.info('%s can keep using %s', bfile_path, usage.asset_path)
asset_pp = self.target / asset_path.relative_to(self.project) asset_pp = self.target / asset_path.relative_to(self.project)
act.new_path = self._packed_paths[asset_path] = asset_pp act.new_path = asset_pp
self._find_new_paths(new_location_paths) self._find_new_paths(new_location_paths)
self._group_rewrites() self._group_rewrites()
@ -102,7 +101,6 @@ class Packer:
assert isinstance(act, AssetAction) assert isinstance(act, AssetAction)
# Like a join, but ignoring the fact that 'path' is absolute. # Like a join, but ignoring the fact that 'path' is absolute.
act.new_path = pathlib.Path(self.target, '_outside_project', *path.parts[1:]) act.new_path = pathlib.Path(self.target, '_outside_project', *path.parts[1:])
self._packed_paths[path] = act.new_path
def _group_rewrites(self): def _group_rewrites(self):
"""For each blend file, collect which fields need rewriting. """For each blend file, collect which fields need rewriting.
@ -158,7 +156,7 @@ class Packer:
for bfile_path, rewrites in self._rewrites.items(): for bfile_path, rewrites in self._rewrites.items():
assert isinstance(bfile_path, pathlib.Path) assert isinstance(bfile_path, pathlib.Path)
bfile_pp = self._packed_paths[bfile_path] bfile_pp = self._actions[bfile_path].new_path
log.info('Rewriting %s', bfile_pp) log.info('Rewriting %s', bfile_pp)
@ -169,7 +167,7 @@ class Packer:
for usage in rewrites: for usage in rewrites:
assert isinstance(usage, result.BlockUsage) assert isinstance(usage, result.BlockUsage)
asset_pp = self._packed_paths[usage.abspath] asset_pp = self._actions[usage.abspath].new_path
assert isinstance(asset_pp, pathlib.Path) assert isinstance(asset_pp, pathlib.Path)
log.debug(' - %s is packed at %s', usage.asset_path, asset_pp) log.debug(' - %s is packed at %s', usage.asset_path, asset_pp)
@ -204,7 +202,7 @@ class Packer:
log.info('Copying %s and dependencies', asset_path) log.info('Copying %s and dependencies', asset_path)
# Copy the asset itself. # Copy the asset itself.
packed_path = self._packed_paths[asset_path] packed_path = self._actions[asset_path].new_path
self._copy_to_target(asset_path, packed_path) self._copy_to_target(asset_path, packed_path)
# Copy its sequence dependencies. # Copy its sequence dependencies.
@ -212,7 +210,7 @@ class Packer:
if not usage.is_sequence: if not usage.is_sequence:
continue continue
first_pp = self._packed_paths[usage.abspath] first_pp = self._actions[usage.abspath].new_path
# In case of globbing, we only support globbing by filename, # In case of globbing, we only support globbing by filename,
# and not by directory. # and not by directory.

View File

@ -38,10 +38,6 @@ class AbstractPackTest(AbstractBlendFileTest):
'textures/Bricks/brick_dotted_04-bump.jpg', 'textures/Bricks/brick_dotted_04-bump.jpg',
'textures/Bricks/brick_dotted_04-color.jpg', 'textures/Bricks/brick_dotted_04-color.jpg',
) )
self.assertEqual({self.blendfiles / fn: self.tpath / fn
for fn in packed_files},
packer._packed_paths)
for pf in packed_files: for pf in packed_files:
path = self.blendfiles / pf path = self.blendfiles / pf
act = packer._actions[path] act = packer._actions[path]
@ -64,15 +60,8 @@ class AbstractPackTest(AbstractBlendFileTest):
'textures/Bricks/brick_dotted_04-bump.jpg', 'textures/Bricks/brick_dotted_04-bump.jpg',
'textures/Bricks/brick_dotted_04-color.jpg', 'textures/Bricks/brick_dotted_04-color.jpg',
) )
self.assertEqual(self.tpath / 'doubly_linked_up.blend',
packer._packed_paths[ppath / 'doubly_linked_up.blend'])
# /tmp/target + /workspace/bat/tests/blendfiles → /tmp/target/workspace/bat/tests/blendfiles # /tmp/target + /workspace/bat/tests/blendfiles → /tmp/target/workspace/bat/tests/blendfiles
extpath = pathlib.Path(self.tpath, '_outside_project', *self.blendfiles.parts[1:]) extpath = pathlib.Path(self.tpath, '_outside_project', *self.blendfiles.parts[1:])
for fn in external_files:
self.assertEqual(extpath / fn,
packer._packed_paths[self.blendfiles / fn],
'for %s' % fn)
act = packer._actions[ppath / 'doubly_linked_up.blend'] act = packer._actions[ppath / 'doubly_linked_up.blend']
self.assertEqual(pack.PathAction.KEEP_PATH, act.path_action, 'for doubly_linked_up.blend') self.assertEqual(pack.PathAction.KEEP_PATH, act.path_action, 'for doubly_linked_up.blend')