generalize handling of ID's so indirect references can be followed
This commit is contained in:
@@ -50,7 +50,6 @@ class FilePath:
|
|||||||
|
|
||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
# Main function to visit paths
|
# Main function to visit paths
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def visit_from_blend(
|
def visit_from_blend(
|
||||||
filepath,
|
filepath,
|
||||||
@@ -142,7 +141,7 @@ class FilePath:
|
|||||||
# follow links (loop over non-filepath ID's)
|
# follow links (loop over non-filepath ID's)
|
||||||
if recursive:
|
if recursive:
|
||||||
for block in iter_blocks_id(b'GR'):
|
for block in iter_blocks_id(b'GR'):
|
||||||
pass
|
yield from FilePath.from_block(block, basedir, rootdir)
|
||||||
|
|
||||||
if recursive:
|
if recursive:
|
||||||
# look into libraries
|
# look into libraries
|
||||||
@@ -161,7 +160,7 @@ class FilePath:
|
|||||||
|
|
||||||
# do this after, incase we mangle names above
|
# do this after, incase we mangle names above
|
||||||
for block in iter_blocks_id(b'LI'):
|
for block in iter_blocks_id(b'LI'):
|
||||||
yield FilePath(block, b'name', basedir), rootdir
|
yield from FilePath.from_block(block, basedir, rootdir)
|
||||||
|
|
||||||
blend.close()
|
blend.close()
|
||||||
|
|
||||||
@@ -193,6 +192,31 @@ class FilePath:
|
|||||||
level=level + 1,
|
level=level + 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------
|
||||||
|
# Direct filepaths from Blocks
|
||||||
|
#
|
||||||
|
# (no expanding or following references)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_block(block, basedir, rootdir):
|
||||||
|
print(block)
|
||||||
|
assert(block.code != b'DATA')
|
||||||
|
fn = FilePath._from_block_dict.get(block.code)
|
||||||
|
if fn is not None:
|
||||||
|
yield from fn(block, basedir, rootdir)
|
||||||
|
|
||||||
|
def _from_block_IM(block, basedir, rootdir):
|
||||||
|
yield FilePath(block, b'name', basedir), rootdir
|
||||||
|
|
||||||
|
def _from_block_LI(block, basedir, rootdir):
|
||||||
|
yield FilePath(block, b'name', basedir), rootdir
|
||||||
|
|
||||||
|
_from_block_dict = {
|
||||||
|
b'IM': _from_block_IM,
|
||||||
|
b'LI': _from_block_LI,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class bf_utils:
|
class bf_utils:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -218,6 +242,7 @@ class ExpandID:
|
|||||||
return
|
return
|
||||||
yield none
|
yield none
|
||||||
def expand_MA(block):
|
def expand_MA(block):
|
||||||
|
print(block)
|
||||||
return
|
return
|
||||||
yield none
|
yield none
|
||||||
def expand_TE(block):
|
def expand_TE(block):
|
||||||
|
Reference in New Issue
Block a user