From 9040d27967a649cb85ba7158cb94b84d6574fcc5 Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Wed, 29 Jun 2016 10:48:09 -0500 Subject: [PATCH] Rework the force types to match case for example, argparse_force_uppercase_type will now correctly parse uARM to uARM --- tools/utils.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/utils.py b/tools/utils.py index 50a985f486..5c64c41e65 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -229,14 +229,10 @@ def argparse_force_type(case): # arguments after converting it's case. Offer a suggestion if the hyphens/underscores # do not match the expected style of the argument. def parse_type(string): - string = case(string) - newstring = string.replace("-","_") - if string in list: - return string - elif string not in list and newstring in list: - raise argparse.ArgumentTypeError("{0} is not a supported {1}. Did you mean {2}?".format(string, type_name, newstring)) - else: - raise argparse.ArgumentTypeError("{0} is not a supported {1}. Supported {1}s are:\n{2}".format(string, type_name, columnate(list))) + for option in list: + if case(string) == case(option): + return option + raise argparse.ArgumentTypeError("{0} is not a supported {1}. Supported {1}s are:\n{2}".format(string, type_name, columnate(list))) return parse_type return middle