From 479d15b32691def9de4f4d792ee077168b956635 Mon Sep 17 00:00:00 2001 From: Humberto Ibarra Date: Mon, 4 Jul 2016 15:33:33 -0500 Subject: yocto-bsp: Refactor script to use argparse instead of optparse Optparse is deprecated and should be avoided. The arparse library is better suited and has more tools to handling the parsing of arguments. This patch makes necessary changes to migrate to the better library and uses arparse subcommand feature to improve organization of this script. [YOCTO #8321] (From meta-yocto rev: 3f45993b96d4d960da0efe8672dc323c9db091a2) Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- scripts/lib/bsp/engine.py | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'scripts/lib/bsp') diff --git a/scripts/lib/bsp/engine.py b/scripts/lib/bsp/engine.py index 760efc7a60..07a15bb90c 100644 --- a/scripts/lib/bsp/engine.py +++ b/scripts/lib/bsp/engine.py @@ -1826,16 +1826,13 @@ def yocto_layer_list_property_values(arch, property, scripts_path, properties_fi print_values(type, values_list) -def yocto_bsp_list(args, scripts_path, properties_file): +def yocto_bsp_list(args, scripts_path): """ Print available architectures, or the complete list of properties defined by the BSP, or the possible values for a particular BSP property. """ - if len(args) < 1: - return False - - if args[0] == "karch": + if args.karch == "karch": lib_path = scripts_path + '/lib' bsp_path = lib_path + '/bsp' arch_path = bsp_path + '/substrate/target/arch' @@ -1844,26 +1841,13 @@ def yocto_bsp_list(args, scripts_path, properties_file): if arch == "common" or arch == "layer": continue print(" %s" % arch) - return True - else: - arch = args[0] - - if len(args) < 2 or len(args) > 3: - return False - - if len(args) == 2: - if args[1] == "properties": - yocto_layer_list_properties(arch, scripts_path, properties_file) - else: - return False + return - if len(args) == 3: - if args[1] == "property": - yocto_layer_list_property_values(arch, args[2], scripts_path, properties_file) - else: - return False + if args.properties: + yocto_layer_list_properties(args.karch, scripts_path, args.properties_file) + elif args.property: + yocto_layer_list_property_values(args.karch, args.property, scripts_path, args.properties_file) - return True def yocto_layer_list(args, scripts_path, properties_file): -- cgit v1.2.3-54-g00ecf