From daa9701354c465f3706eae12934a7bb3ea2ce2da Mon Sep 17 00:00:00 2001 From: David Howells Date: Sat, 12 Apr 2014 15:51:03 +0100 Subject: [PATCH] Provide separate arg interpretation functions for multivalued arguments Provide separate arg interpretation functions for multivalued arguments so that the single-valued versions return a non-list and the multivalued returns a list. Signed-off-by: David Howells --- suite/argparse.py | 17 +++++++++++++++++ suite/commands/bos/getdate.py | 4 ++-- suite/commands/bos/status.py | 2 +- suite/commands/vos/listvldb.py | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/suite/argparse.py b/suite/argparse.py index fcda4a6..bcc2fa1 100644 --- a/suite/argparse.py +++ b/suite/argparse.py @@ -39,13 +39,25 @@ def get_vlservers(switch, params): def get_volume_name(switch, params): return params[0] +def get_volume_names(switch, params): + return params + def get_machine_name(switch, params): + return params[0] + +def get_machine_names(switch, params): return params def get_path_name(switch, params): + return params[0] + +def get_path_names(switch, params): return params def get_file_name(switch, params): + return params[0] + +def get_file_names(switch, params): return params def get_partition_id(switch, params): @@ -59,6 +71,11 @@ def get_uuid(switch, params): from afs.lib.uuid import str2uuid return str2uuid(params[0]) +def get_string(switch, params): + return params[0] + +def get_strings(switch, params): + return params def get_dummy(switch, params): return params diff --git a/suite/commands/bos/getdate.py b/suite/commands/bos/getdate.py index a019d94..9b1fd96 100644 --- a/suite/commands/bos/getdate.py +++ b/suite/commands/bos/getdate.py @@ -29,7 +29,7 @@ help = "Display the time stamps on an AFS binary file" command_arguments = [ [ "server", get_bosserver, "rs", "" ], - [ "file", get_file_name, "rm", "+" ], + [ "file", get_file_names, "rm", "+" ], [ "dir", get_path_name, "os", "" ], [ "cell", get_cell, "os", "" ], [ "noauth", get_auth, "fn" ], @@ -52,7 +52,7 @@ def main(params): bos_conn = cell.open_bos_server(params["server"], params) if "dir" in params: - d = params["dir"][0] + d = params["dir"] else: d = "/usr/afs/bin" diff --git a/suite/commands/bos/status.py b/suite/commands/bos/status.py index 413e1bd..789b453 100644 --- a/suite/commands/bos/status.py +++ b/suite/commands/bos/status.py @@ -31,7 +31,7 @@ help = "Display the status of server processes" command_arguments = [ [ "server", get_bosserver, "rs", "" ], - [ "instance", get_file_name, "om", "+" ], + [ "instance", get_file_names, "om", "+" ], [ "long", get_dummy, "fn" ], [ "cell", get_cell, "os", "" ], [ "noauth", get_auth, "fn" ], diff --git a/suite/commands/vos/listvldb.py b/suite/commands/vos/listvldb.py index 0859cea..db310e9 100644 --- a/suite/commands/vos/listvldb.py +++ b/suite/commands/vos/listvldb.py @@ -69,7 +69,7 @@ def main(params): quiet = "quiet" in params if "name" in params: - ret = kafs.VL_GetEntryByName(z_conn, params["name"][0]) + ret = kafs.VL_GetEntryByName(z_conn, params["name"]) vldb = ret.entry print_record(params, vldb) return -- 2.49.0