Rework the force types to match case

for example, argparse_force_uppercase_type will now correctly parse uARM to uARM
pull/2010/head
Jimmy Brisson 2016-06-29 10:48:09 -05:00
parent b4b514ea2f
commit 9040d27967
1 changed files with 4 additions and 8 deletions

View File

@ -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