From 8b1085edd1156c0f83500d94084a0a142bb7aae5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 5 Nov 2014 14:48:10 +0100 Subject: [PATCH] rename/reshuffle modules --- client/cli/bam.py | 7 ++++++ {packer => modules}/blendfile.py | 0 packer/packer.py => modules/blendfile_pack.py | 24 +++++++++++++------ .../blendfile_pack_restore.py | 0 {packer => modules}/blendfile_path_walker.py | 0 webservice/bam/application/__init__.py | 21 +++------------- 6 files changed, 27 insertions(+), 25 deletions(-) rename {packer => modules}/blendfile.py (100%) rename packer/packer.py => modules/blendfile_pack.py (95%) rename packer/packer_restore.py => modules/blendfile_pack_restore.py (100%) rename {packer => modules}/blendfile_path_walker.py (100%) diff --git a/client/cli/bam.py b/client/cli/bam.py index d1d2205..b2ffcc7 100755 --- a/client/cli/bam.py +++ b/client/cli/bam.py @@ -300,6 +300,13 @@ class bam_utils: print(" %s" % name_short) + @staticmethod + def deps(paths): + # TODO(cam) multiple paths + path = paths[0] + + + def subcommand_checkout_cb(args): bam_utils.checkout(args.paths) diff --git a/packer/blendfile.py b/modules/blendfile.py similarity index 100% rename from packer/blendfile.py rename to modules/blendfile.py diff --git a/packer/packer.py b/modules/blendfile_pack.py similarity index 95% rename from packer/packer.py rename to modules/blendfile_pack.py index 7121726..2e11da5 100755 --- a/packer/packer.py +++ b/modules/blendfile_pack.py @@ -69,7 +69,7 @@ def pack(blendfile_src, blendfile_dst, mode='FILE', WRITE_JSON_REMAP = True if report is None: - raise Exception("report not set!") + report = lambda msg: msg yield report("%s: %r...\n" % (colorize("\nscanning deps", color='bright_green'), blendfile_src)) @@ -282,6 +282,9 @@ def create_argparse(): parser.add_argument( "-s", "--paths_remap", dest="paths_remap", metavar='FILE', help="Write out the original paths to a JSON file") + parser.add_argument( + "-u", "--paths_uuid", dest="paths_uuid", metavar='FILE', + help="Write out the original paths UUID to a JSON file") return parser @@ -296,13 +299,17 @@ def main(): deps_remap = {} if args.deps_remap else None paths_remap = {} if args.paths_remap else None + paths_uuid = {} if args.paths_uuid else None - pack(args.path_src.encode(encoding), - args.path_dst.encode(encoding), - args.mode, - deps_remap, - paths_remap, - ) + for msg in pack( + args.path_src.encode(encoding), + args.path_dst.encode(encoding), + args.mode, + deps_remap=deps_remap, + paths_remap=paths_remap, + paths_uuid=paths_uuid, + ): + print(msg) def write_dict_as_json(fn, dct): with open(fn, 'w', encoding='utf-8') as f: @@ -320,6 +327,9 @@ def main(): if paths_remap is not None: write_dict_as_json(args.paths_remap, paths_remap) + if paths_uuid is not None: + write_dict_as_json(args.paths_uuid, paths_uuid) + del write_dict_as_json if __name__ == "__main__": diff --git a/packer/packer_restore.py b/modules/blendfile_pack_restore.py similarity index 100% rename from packer/packer_restore.py rename to modules/blendfile_pack_restore.py diff --git a/packer/blendfile_path_walker.py b/modules/blendfile_path_walker.py similarity index 100% rename from packer/blendfile_path_walker.py rename to modules/blendfile_path_walker.py diff --git a/webservice/bam/application/__init__.py b/webservice/bam/application/__init__.py index a0c5740..a2faa38 100644 --- a/webservice/bam/application/__init__.py +++ b/webservice/bam/application/__init__.py @@ -21,7 +21,7 @@ # Ensure module path import os import sys -path = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "modules")) +path = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "modules")) if path not in sys.path: sys.path.append(path) del os, sys, path @@ -255,28 +255,13 @@ class FileAPI(Resource): import os assert(os.path.exists(filepath) and not os.path.isdir(filepath)) - modpath = \ - os.path.normpath( - os.path.abspath( - os.path.join( - os.path.dirname(__file__), - "..", - "..", - "..", - "packer"))) - - import sys - if modpath not in sys.path: - sys.path.append(modpath) - del modpath - - import packer + import blendfile_pack print(" Source path:", filepath) print(" Zip path:", filepath_zip) try: - yield from packer.pack( + yield from blendfile_pack.pack( filepath.encode('utf-8'), filepath_zip[-1].encode('utf-8'), mode='ZIP', # TODO(cam) this just means the json is written in the zip deps_remap={}, paths_remap={}, paths_uuid={},