Fix: Exception in conf utils
The bug was related to trying to split a string with unstript spaces in the action parameter. It resulted in a unbound error as there was no previous raise when getting the key from args_funcs. The fix is twofold, it makes sure that we raise the keyerror if we're trying to grab a non existing key and we're stripping the spaces from the action before splitting. This should fix both the unbound error and the not being able to resolve correct actions.
This commit is contained in:
parent
e35c3cc913
commit
12975347ee
@ -228,19 +228,28 @@ def parse_kittens_shortcut(sc):
|
|||||||
|
|
||||||
|
|
||||||
def parse_kittens_func_args(action, args_funcs):
|
def parse_kittens_func_args(action, args_funcs):
|
||||||
parts = action.split(' ', 1)
|
parts = action.strip().split(' ', 1)
|
||||||
func = parts[0]
|
func = parts[0]
|
||||||
if len(parts) == 1:
|
if len(parts) == 1:
|
||||||
return func, ()
|
return func, ()
|
||||||
rest = parts[1]
|
rest = parts[1]
|
||||||
parser = args_funcs.get(func)
|
|
||||||
if parser is not None:
|
try:
|
||||||
|
parser = args_funcs[func]
|
||||||
|
except KeyError:
|
||||||
|
raise KeyError(
|
||||||
|
"Couldn't get valid key from {}. Check if input action: "
|
||||||
|
"{} is valid".format(parts, action)
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
func, args = parser(func, rest)
|
func, args = parser(func, rest)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise ValueError('Unknown key action: {}'.format(action))
|
raise ValueError('Unknown key action: {}'.format(action))
|
||||||
|
|
||||||
if not isinstance(args, (list, tuple)):
|
if not isinstance(args, (list, tuple)):
|
||||||
args = (args,)
|
args = (args,)
|
||||||
|
|
||||||
return func, tuple(args)
|
return func, tuple(args)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user