From 3a31d2cc5d657ee79c4478879729821ba8764769 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 13 Jan 2020 19:03:35 -0800 Subject: [PATCH] Revert "Improved the iter_parsers function of the argparse_to_json.py to allow" This reverts commit 4140f8e8e69585d1a421757d1fc1944b6de6bf36. --- gooey/python_bindings/argparse_to_json.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/gooey/python_bindings/argparse_to_json.py b/gooey/python_bindings/argparse_to_json.py index 44b854b..f20b0ac 100644 --- a/gooey/python_bindings/argparse_to_json.py +++ b/gooey/python_bindings/argparse_to_json.py @@ -19,6 +19,7 @@ from uuid import uuid4 from gooey.python_bindings.gooey_parser import GooeyParser from gooey.util.functional import merge, getin, identity, assoc + VALID_WIDGETS = ( 'FileChooser', 'MultiFileChooser', @@ -126,24 +127,10 @@ def assert_subparser_constraints(parser): "when subparsers are present.") -def iter_parsers(parser, parents=()): - ''' - Recursively iterate over name, parser pairs - - If one of the child actions contains a sub_parser is going to be called recursively to iter_parsers - - :parser current parser to extract his actions - :parents tuple of previous actions parsers - :return a generator of all the actions and sub actions - ''' +def iter_parsers(parser): + ''' Iterate over name, parser pairs ''' try: - for name, sub_parser in get_subparser(parser._actions).choices.items(): - chain = parents + (name,) - if has_subparsers(sub_parser._actions): - yield from iter_parsers(sub_parser, parents=chain) - else: - yield ' '.join(chain), sub_parser - + return get_subparser(parser._actions).choices.items() except: return iter([('::gooey/default', parser)]) @@ -269,7 +256,7 @@ def categorize(actions, widget_dict, options): elif is_standard(action): yield action_to_json(action, _get_widget(action, 'TextField'), options) - + elif is_file(action): yield action_to_json(action, _get_widget(action, 'FileSaver'), options)