diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-07 00:41:06 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-07 00:41:06 -0400 |
commit | ee15a3df954b3a9551f29f72f097134a6a5300cc (patch) | |
tree | 778e049f2ed05cda1a77084ac27cf7fbf12c28ec /cmd2/argparse_completer.py | |
parent | 3685eff4c61153bb626f8ce2873424b32a9df790 (diff) | |
download | cmd2-git-ee15a3df954b3a9551f29f72f097134a6a5300cc.tar.gz |
Removed more suppression of exceptions in argparse completer to help with debugging tab-completion functions
Diffstat (limited to 'cmd2/argparse_completer.py')
-rw-r--r-- | cmd2/argparse_completer.py | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py index 659742bb..edfaeec4 100644 --- a/cmd2/argparse_completer.py +++ b/cmd2/argparse_completer.py @@ -667,7 +667,7 @@ class AutoCompleter(object): if callable(arg_choices[0]): completer = arg_choices[0] - elif isinstance(arg_choices[0], str) and callable(getattr(self._cmd2_app, arg_choices[0])): + else: completer = getattr(self._cmd2_app, arg_choices[0]) # extract the positional and keyword arguments from the tuple @@ -701,32 +701,17 @@ class AutoCompleter(object): # is the argument a string? If so, see if we can find an attribute in the # application matching the string. if isinstance(args, str): - try: - args = getattr(self._cmd2_app, args) - except AttributeError: - # Couldn't find anything matching the name - return [] + args = getattr(self._cmd2_app, args) # is the provided argument a callable. If so, call it if callable(args): try: - try: - args = args(self._cmd2_app) - except TypeError: - args = args() + args = args(self._cmd2_app) except TypeError: - return [] - - try: - iter(args) - except TypeError: - pass - else: - # filter out arguments we already used - args = [arg for arg in args if arg not in used_values] + args = args() - if len(args) > 0: - return args + # filter out arguments we already used + return [arg for arg in args if arg not in used_values] return [] |