test commit, WIP debugging
This commit is contained in:
@@ -18,9 +18,23 @@
|
|||||||
#
|
#
|
||||||
# ***** END GPL LICENCE BLOCK *****
|
# ***** END GPL LICENCE BLOCK *****
|
||||||
|
|
||||||
VERBOSE = False
|
VERBOSE = True
|
||||||
TIMEIT = True
|
TIMEIT = True
|
||||||
|
|
||||||
|
if VERBOSE:
|
||||||
|
_A = open("/tmp/a.log", 'w')
|
||||||
|
class log_deps:
|
||||||
|
@staticmethod
|
||||||
|
def info(msg):
|
||||||
|
_A.write(msg)
|
||||||
|
_A.write("\n")
|
||||||
|
|
||||||
|
def set_as_str(s):
|
||||||
|
if s is None:
|
||||||
|
return "None"
|
||||||
|
else:
|
||||||
|
return (", ".join(sorted(i.decode('ascii') for i in sorted(s))))
|
||||||
|
|
||||||
class FilePath:
|
class FilePath:
|
||||||
"""
|
"""
|
||||||
Tiny filepath class to hide blendfile.
|
Tiny filepath class to hide blendfile.
|
||||||
@@ -74,13 +88,18 @@ class FilePath:
|
|||||||
# {lib_path: set([block id's ...])}
|
# {lib_path: set([block id's ...])}
|
||||||
lib_visit=None,
|
lib_visit=None,
|
||||||
):
|
):
|
||||||
|
# print(level, block_codes)
|
||||||
import os
|
import os
|
||||||
|
|
||||||
if VERBOSE:
|
if VERBOSE:
|
||||||
indent_str = " " * level
|
indent_str = " " * level
|
||||||
print(indent_str + "Opening:", filepath)
|
print(indent_str + "Opening:", filepath)
|
||||||
print(indent_str + "... blocks:", block_codes)
|
# print(indent_str + "... blocks:", block_codes)
|
||||||
|
|
||||||
|
|
||||||
|
log_deps.info("~")
|
||||||
|
log_deps.info("%s%s" % (indent_str, filepath.decode('utf-8')))
|
||||||
|
log_deps.info("%s%s" % (indent_str, set_as_str(block_codes)))
|
||||||
|
|
||||||
|
|
||||||
basedir = os.path.dirname(os.path.abspath(filepath))
|
basedir = os.path.dirname(os.path.abspath(filepath))
|
||||||
@@ -92,17 +111,21 @@ class FilePath:
|
|||||||
# same datablock more then once
|
# same datablock more then once
|
||||||
expand_codes = set()
|
expand_codes = set()
|
||||||
|
|
||||||
def expand_codes_add_test(block):
|
# only for this block
|
||||||
|
def _expand_codes_add_test(block):
|
||||||
# we could investigate a better way...
|
# we could investigate a better way...
|
||||||
# Not to be accessing ID blocks at this point. but its harmless
|
# Not to be accessing ID blocks at this point. but its harmless
|
||||||
if block.code == b'ID':
|
if block.code == b'ID':
|
||||||
|
if recursive:
|
||||||
|
lib_all
|
||||||
return False
|
return False
|
||||||
len_prev = len(expand_codes)
|
else:
|
||||||
expand_codes.add(block[b'id.name'])
|
len_prev = len(expand_codes)
|
||||||
return (len_prev != len(expand_codes))
|
expand_codes.add(block[b'id.name'])
|
||||||
|
return (len_prev != len(expand_codes))
|
||||||
|
|
||||||
def block_expand(block, code):
|
def block_expand(block, code):
|
||||||
if expand_codes_add_test(block):
|
if _expand_codes_add_test(block):
|
||||||
yield block
|
yield block
|
||||||
|
|
||||||
fn = ExpandID.expand_funcs.get(code)
|
fn = ExpandID.expand_funcs.get(code)
|
||||||
@@ -129,10 +152,16 @@ class FilePath:
|
|||||||
if expand_codes is None:
|
if expand_codes is None:
|
||||||
iter_blocks_lib = lambda: blend.find_blocks_from_code(b'ID')
|
iter_blocks_lib = lambda: blend.find_blocks_from_code(b'ID')
|
||||||
else:
|
else:
|
||||||
iter_blocks_lib = lambda: (block
|
# iter_blocks_lib = lambda: (block
|
||||||
for block in blend.find_blocks_from_code(b'ID')
|
# for block in blend.find_blocks_from_code(b'ID')
|
||||||
if block[b'name'] in expand_codes)
|
# if block[b'name'] in expand_codes)
|
||||||
|
def iter_blocks_lib():
|
||||||
|
for block in blend.find_blocks_from_code(b'ID'):
|
||||||
|
# if block[b'name'] in expand_codes:
|
||||||
|
log_deps.info("%ssearching: %s" % (indent_str, block[b'name'].decode('ascii')))
|
||||||
|
if block[b'name'] in expand_codes:
|
||||||
|
print("AAA", block[b'name'], expand_codes)
|
||||||
|
yield block
|
||||||
|
|
||||||
if temp_remap_cb is not None:
|
if temp_remap_cb is not None:
|
||||||
filepath_tmp = temp_remap_cb(filepath, level)
|
filepath_tmp = temp_remap_cb(filepath, level)
|
||||||
@@ -156,12 +185,17 @@ class FilePath:
|
|||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if VERBOSE:
|
# if VERBOSE:
|
||||||
print(" Scanning", code)
|
# print(" Scanning", code)
|
||||||
|
|
||||||
for block in iter_blocks_id(code):
|
for block in iter_blocks_id(code):
|
||||||
yield from FilePath.from_block(block, basedir, rootdir, level)
|
yield from FilePath.from_block(block, basedir, rootdir, level)
|
||||||
|
|
||||||
|
# print("A:", expand_codes)
|
||||||
|
# print("B:", block_codes)
|
||||||
|
if VERBOSE:
|
||||||
|
log_deps.info("%s%s" % (indent_str, set_as_str(expand_codes)))
|
||||||
|
|
||||||
if recursive:
|
if recursive:
|
||||||
# look into libraries
|
# look into libraries
|
||||||
lib_all = {}
|
lib_all = {}
|
||||||
@@ -175,6 +209,7 @@ class FilePath:
|
|||||||
|
|
||||||
# get all data needed to read the blend files here (it will be freed!)
|
# get all data needed to read the blend files here (it will be freed!)
|
||||||
# lib is an address at the moment, we only use as a way to group
|
# lib is an address at the moment, we only use as a way to group
|
||||||
|
print("OOO", block[b'name'])
|
||||||
lib_all.setdefault(lib_path, set()).add(block[b'name'])
|
lib_all.setdefault(lib_path, set()).add(block[b'name'])
|
||||||
|
|
||||||
# do this after, incase we mangle names above
|
# do this after, incase we mangle names above
|
||||||
@@ -187,8 +222,10 @@ class FilePath:
|
|||||||
# Handle Recursive
|
# Handle Recursive
|
||||||
if recursive:
|
if recursive:
|
||||||
# now we've closed the file, loop on other files
|
# now we've closed the file, loop on other files
|
||||||
for lib_path, lib_block_codes in lib_all.items():
|
|
||||||
lib_path_abs = utils.compatpath(utils.abspath(lib_path, basedir))
|
# note, sorting - isn't needed, it just gives predictable load-order.
|
||||||
|
for lib_path, lib_block_codes in sorted(lib_all.items()):
|
||||||
|
lib_path_abs = os.path.normpath(utils.compatpath(utils.abspath(lib_path, basedir)))
|
||||||
|
|
||||||
# if we visited this before,
|
# if we visited this before,
|
||||||
# check we don't follow the same links more than once
|
# check we don't follow the same links more than once
|
||||||
@@ -197,10 +234,13 @@ class FilePath:
|
|||||||
# don't touch them again
|
# don't touch them again
|
||||||
lib_block_codes_existing.update(lib_block_codes)
|
lib_block_codes_existing.update(lib_block_codes)
|
||||||
|
|
||||||
|
# print("looking for", lib_block_codes)
|
||||||
|
|
||||||
# import IPython; IPython.embed()
|
# import IPython; IPython.embed()
|
||||||
if VERBOSE:
|
if VERBOSE:
|
||||||
print((indent_str + " "), "Library: ", filepath, " -> ", lib_path_abs, sep="")
|
print((indent_str + " "), "Library: ", filepath, " -> ", lib_path_abs, sep="")
|
||||||
print((indent_str + " "), lib_block_codes)
|
# print((indent_str + " "), lib_block_codes)
|
||||||
|
print(level)
|
||||||
yield from FilePath.visit_from_blend(
|
yield from FilePath.visit_from_blend(
|
||||||
lib_path_abs,
|
lib_path_abs,
|
||||||
readonly=readonly,
|
readonly=readonly,
|
||||||
@@ -520,7 +560,11 @@ def pack(blendfile_src, blendfile_dst):
|
|||||||
|
|
||||||
del lib_visit
|
del lib_visit
|
||||||
|
|
||||||
# handle the
|
if TIMEIT:
|
||||||
|
print(" Time: %.4f" % (time.time() - t))
|
||||||
|
|
||||||
|
# ----------------
|
||||||
|
# Handle File Copy
|
||||||
blendfile_dst_tmp = temp_remap_cb(blendfile_src, 0)
|
blendfile_dst_tmp = temp_remap_cb(blendfile_src, 0)
|
||||||
shutil.move(blendfile_dst_tmp, blendfile_dst)
|
shutil.move(blendfile_dst_tmp, blendfile_dst)
|
||||||
path_temp_files.remove(blendfile_dst_tmp)
|
path_temp_files.remove(blendfile_dst_tmp)
|
||||||
@@ -538,9 +582,6 @@ def pack(blendfile_src, blendfile_dst):
|
|||||||
|
|
||||||
print(" Written:", blendfile_dst)
|
print(" Written:", blendfile_dst)
|
||||||
|
|
||||||
if TIMEIT:
|
|
||||||
print(" Time: %.4f" % (time.time() - t))
|
|
||||||
|
|
||||||
|
|
||||||
def create_argparse():
|
def create_argparse():
|
||||||
import os
|
import os
|
||||||
|
Reference in New Issue
Block a user