Added block walker implementations + tests

This commit is contained in:
Sybren A. Stüvel
2018-02-27 17:30:28 +01:00
parent 6b9c0a3f95
commit 65b690e998
29 changed files with 337 additions and 75 deletions
+3 -2
View File
@@ -1,9 +1,10 @@
from . import BlendFileBlock
from .dna import FieldPath
def listbase(block: BlendFileBlock) -> BlendFileBlock:
def listbase(block: BlendFileBlock, next_path: FieldPath=b'next') -> BlendFileBlock:
"""Generator, yields all blocks in the ListBase linked list."""
while block:
yield block
next_ptr = block[b'next']
next_ptr = block[next_path]
block = block.bfile.find_block_from_address(next_ptr)