Skip to content

Commit 9040d27

Browse files
committed
Rework the force types to match case
for example, argparse_force_uppercase_type will now correctly parse uARM to uARM
1 parent b4b514e commit 9040d27

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

tools/utils.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,10 @@ def middle(list, type_name):
229229
# arguments after converting it's case. Offer a suggestion if the hyphens/underscores
230230
# do not match the expected style of the argument.
231231
def parse_type(string):
232-
string = case(string)
233-
newstring = string.replace("-","_")
234-
if string in list:
235-
return string
236-
elif string not in list and newstring in list:
237-
raise argparse.ArgumentTypeError("{0} is not a supported {1}. Did you mean {2}?".format(string, type_name, newstring))
238-
else:
239-
raise argparse.ArgumentTypeError("{0} is not a supported {1}. Supported {1}s are:\n{2}".format(string, type_name, columnate(list)))
232+
for option in list:
233+
if case(string) == case(option):
234+
return option
235+
raise argparse.ArgumentTypeError("{0} is not a supported {1}. Supported {1}s are:\n{2}".format(string, type_name, columnate(list)))
240236
return parse_type
241237
return middle
242238

0 commit comments

Comments
 (0)