Browse Source

Added support for argparse.FileType to json mapper issue #59

pull/69/head
chriskiehl 9 years ago
parent
commit
2249604446
1 changed files with 6 additions and 2 deletions
  1. 8
      gooey/python_bindings/argparse_to_json.py

8
gooey/python_bindings/argparse_to_json.py

@ -9,6 +9,7 @@ from argparse import (
_StoreFalseAction,
_StoreTrueAction,
ArgumentParser)
import argparse
import itertools
@ -37,7 +38,7 @@ def convert(parser):
for mutex_action in group_actions._group_actions]
base_actions = [(action, widget_dict.get(action.dest, None))
base_actions = [(action, get_widget(action, widget_dict))
for action in parser._actions
if action not in mutually_exclusive_group]
@ -63,7 +64,10 @@ def convert(parser):
}
def get_widget(action, widgets):
supplied_widget = widgets.get(action.dest, None)
type_arg_widget = 'FileChooser' if type(action.type) == type(argparse.FileType) else None
return supplied_widget or type_arg_widget or None
def get_required_and_positional_args(actions):

Loading…
Cancel
Save