From 3599de21ae81da27049e675ef157d0b5efdfbc11 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 30 Oct 2014 09:38:17 +0100 Subject: [PATCH] Cleanup --- packer/blendfile_path_walker.py | 15 +++++++-------- packer/packer.py | 10 ++-------- packer/packer_restore.py | 2 -- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/packer/blendfile_path_walker.py b/packer/blendfile_path_walker.py index 9a0a1b7..86a27f5 100644 --- a/packer/blendfile_path_walker.py +++ b/packer/blendfile_path_walker.py @@ -37,9 +37,14 @@ class C_defs: SEQ_TYPE_MASK = 7 SEQ_TYPE_EFFECT = 8 + IMA_SRC_FILE = 1 + IMA_SRC_SEQUENCE = 2 + IMA_SRC_MOVIE = 3 + if VERBOSE: _A = open("/tmp/a.log", 'w') + class log_deps: @staticmethod def info(msg): @@ -50,8 +55,7 @@ if VERBOSE: if s is None: return "None" else: - return (", ".join(sorted(i.decode('ascii') for i in sorted(s)))) - + return (", ".join(sorted(i.decode('ascii') for i in sorted(s)))) class FPElem: @@ -163,12 +167,10 @@ class FilePath: # print(indent_str + "Opening:", filepath) # 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)) if rootdir is None: rootdir = basedir @@ -369,8 +371,7 @@ class FilePath: @staticmethod def _from_block_IM(block, basedir, extra_info, level): - # (IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE) - if block[b'source'] not in {1, 2, 3}: + if block[b'source'] not in {C_defs.IMA_SRC_FILE, C_defs.IMA_SRC_SEQUENCE, C_defs.IMA_SRC_MOVIE}: return if block[b'packedfile']: return @@ -596,7 +597,6 @@ class ExpandID: for item in bf_utils.iter_ListBase(block.get_pointer(b'base.first')): yield item.get_pointer(b'object', sdna_index_refine=sdna_index_Base) - @staticmethod def expand_GR(block): # 'Group' sdna_index_GroupObject = block.file.sdna_index_from_id[b'GroupObject'] @@ -640,4 +640,3 @@ class utils: def compatpath(path): # keep '//' return path[:2] + path[2:].replace(b'/', b'\\') - diff --git a/packer/packer.py b/packer/packer.py index 4bb7ad5..7114141 100755 --- a/packer/packer.py +++ b/packer/packer.py @@ -41,7 +41,6 @@ def pack(blendfile_src, blendfile_dst, mode='FILE', pathmap=None): # this means that the same libs wont be touched many times to modify the same data # also prevents cyclic loops from crashing. - import os import shutil @@ -74,7 +73,7 @@ def pack(blendfile_src, blendfile_dst, mode='FILE', pathmap=None): path_temp_files.add(filepath_tmp) return filepath_tmp - base_dir_src = os.path.dirname(blendfile_src) + # base_dir_src = os.path.dirname(blendfile_src) base_dir_dst = os.path.dirname(blendfile_dst) base_dir_dst_subdir = os.path.join(base_dir_dst, SUBDIR) @@ -127,15 +126,11 @@ def pack(blendfile_src, blendfile_dst, mode='FILE', pathmap=None): if pathmap is not None: blendfile_src_basename = os.path.basename(blendfile_src).decode('utf-8') blendfile_dst_basename = os.path.basename(blendfile_dst).decode('utf-8') - print("AAAAA") - print(blendfile_src_basename, blendfile_dst_basename) if blendfile_src_basename != blendfile_dst_basename: pathmap[blendfile_dst_basename] = pathmap[blendfile_src_basename] del pathmap[blendfile_src_basename] - # del blendfile_src_basename, blendfile_dst_basename - # print(pathmap) - + del blendfile_src_basename, blendfile_dst_basename # -------------------- # Handle File Copy/Zip @@ -247,4 +242,3 @@ def main(): if __name__ == "__main__": main() - diff --git a/packer/packer_restore.py b/packer/packer_restore.py index a587d46..672665d 100755 --- a/packer/packer_restore.py +++ b/packer/packer_restore.py @@ -46,7 +46,6 @@ def blendfile_remap(blendfile_src, blendpath_dst, path_remap): return filepath_tmp - for fp, (rootdir, fp_blend_basename) in blendfile_path_walker.FilePath.visit_from_blend( blendfile_src, readonly=False, @@ -128,4 +127,3 @@ def main(): if __name__ == "__main__": main() -