Removed find_block_from_address() in favour of dereference_pointer()

This commit is contained in:
Sybren A. Stüvel 2018-03-08 11:08:36 +01:00
parent 9c9323b170
commit 9af913d69a
2 changed files with 3 additions and 10 deletions

View File

@ -229,15 +229,6 @@ class BlendFile:
assert isinstance(code, bytes) assert isinstance(code, bytes)
return self.code_index[code] return self.code_index[code]
def find_block_from_address(self, address: int) -> typing.Optional['BlendFileBlock']:
"""Return the block at that address, or None if not found.
:param address: the BlendFileBlock.addr_old value
"""
# TODO(Sybren): mark as deprecated in favour of dereference_pointer().
assert type(address) is int
return self.block_from_addr.get(address)
def close(self): def close(self):
"""Close the blend file. """Close the blend file.

View File

@ -11,7 +11,9 @@ def listbase(block: BlendFileBlock, next_path: FieldPath = b'next') \
while block: while block:
yield block yield block
next_ptr = block[next_path] next_ptr = block[next_path]
block = block.bfile.find_block_from_address(next_ptr) if next_ptr == 0:
break
block = block.bfile.dereference_pointer(next_ptr)
def sequencer_strips(sequence_editor: BlendFileBlock) \ def sequencer_strips(sequence_editor: BlendFileBlock) \