From ab8f30f2128143d14e59eec539408cf95cced5b0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 May 2015 22:48:28 +1000 Subject: [PATCH] Add bam pack, --mode=FILE option --- bam/__init__.py | 2 +- bam/cli.py | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bam/__init__.py b/bam/__init__.py index 9a99c9c..63e8810 100644 --- a/bam/__init__.py +++ b/bam/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import sys -__version__ = "0.0.4.4" +__version__ = "0.0.4.5" def main(argv=sys.argv): from .cli import main diff --git a/bam/cli.py b/bam/cli.py index 4719646..be8677e 100755 --- a/bam/cli.py +++ b/bam/cli.py @@ -1317,6 +1317,7 @@ class bam_commands: def pack( paths, output, + mode, all_deps=False, use_quiet=False, compress_level=-1, @@ -1328,6 +1329,9 @@ class bam_commands: path = paths[0] del paths + if output is None: + fatal("Output path must be given when packing with: --mode=FILE") + if use_quiet: report = lambda msg: None else: @@ -1336,7 +1340,7 @@ class bam_commands: for msg in blendfile_pack.pack( path.encode('utf-8'), output.encode('utf-8'), - 'ZIP', + mode=mode, all_deps=all_deps, compress_level=compress_level, report=report, @@ -1655,7 +1659,13 @@ def create_argparse_pack(subparsers): help="Path(s) to operate on", ) subparse.add_argument( - "-o", "--output", dest="output", metavar='ZIP', required=False, + "-o", "--output", dest="output", metavar='FILE', required=False, + help="Output file or a directory when multiple inputs are passed", + ) + subparse.add_argument( + "-m", "--mode", dest="mode", metavar='MODE', required=False, + default='ZIP', + choices=('ZIP', 'FILE'), help="Output file or a directory when multiple inputs are passed", ) @@ -1665,7 +1675,10 @@ def create_argparse_pack(subparsers): func=lambda args: bam_commands.pack( args.paths, - args.output or (os.path.splitext(args.paths[0])[0] + ".zip"), + args.output or + ((os.path.splitext(args.paths[0])[0] + ".zip") + if args.mode == 'ZIP' else None), + args.mode, all_deps=args.all_deps, use_quiet=args.use_quiet, compress_level=args.compress_level),