From 5388aade23090ad01dc224bc4ad981c57938e700 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 17 Dec 2014 16:28:40 +0100 Subject: [PATCH] bam cli: add --quiet argument (only used for packing) --- client/cli/bam.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/client/cli/bam.py b/client/cli/bam.py index 1487532..861944e 100755 --- a/client/cli/bam.py +++ b/client/cli/bam.py @@ -821,7 +821,12 @@ class bam_commands: print(" %r -> (%r = %r) %s" % (f_src, f_dst, f_dst_abs, f_status)) @staticmethod - def pack(paths, output, all_deps=False): + def pack( + paths, + output, + all_deps=False, + use_quiet=False, + ): # Local packing (don't use any project/session stuff) import blendfile_pack @@ -829,13 +834,19 @@ class bam_commands: path = paths[0] del paths + if use_quiet: + report = lambda msg: None + else: + report = lambda msg: print(msg, end="") + for msg in blendfile_pack.pack( path.encode('utf-8'), output.encode('utf-8'), 'ZIP', all_deps=all_deps, + report=report, ): - print(msg, end="") + pass @staticmethod def remap_start( @@ -914,6 +925,7 @@ def init_argparse_common( subparse, use_json=False, use_all_deps=False, + use_quiet=False, ): if use_json: subparse.add_argument( @@ -925,6 +937,11 @@ def init_argparse_common( "-a", "--all-deps", dest="all_deps", action='store_true', help="Follow all dependencies (unused indirect dependencies too)", ) + if use_quiet: + subparse.add_argument( + "-q", "--quiet", dest="use_quiet", action='store_true', + help="Suppress status output", + ) def create_argparse_init(subparsers): @@ -1109,14 +1126,15 @@ def create_argparse_pack(subparsers): help="Output file or a directory when multiple inputs are passed", ) - init_argparse_common(subparse, use_all_deps=True) + init_argparse_common(subparse, use_all_deps=True, use_quiet=True) subparse.set_defaults( func=lambda args: bam_commands.pack( args.paths, args.output, - all_deps=args.all_deps), + all_deps=args.all_deps, + use_quiet=args.use_quiet), )