Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def extract_groups(action_group):
'''
Recursively extract argument groups and associated actions
from ParserGroup objects
'''
return {
'name': action_group.title,
'description': action_group.description,
'items': [action for action in action_group._group_actions
if not is_help_message(action)],
'groups': [extract_groups(group)
for group in action_group._action_groups],
'options': merge(group_defaults,
getattr(action_group, 'gooey_options', {}))
}
return {
'id': action.option_strings[0] if action.option_strings else action.dest,
'type': widget,
'cli_type': choose_cli_type(action),
'required': action.required,
'data': {
'display_name': action.metavar or action.dest,
'help': action.help,
'required': action.required,
'nargs': action.nargs or '',
'commands': action.option_strings,
'choices': action.choices or [],
'default': clean_default(action.default),
'dest': action.dest,
},
'options': merge(base, options.get(action.dest) or {})
}
def action_to_json(action, widget, options):
if action.required:
# check that it's present and not just spaces
validator = 'user_input and not user_input.isspace()'
error_msg = 'This field is required'
else:
# not required; do nothing;
validator = 'True'
error_msg = ''
base = merge(item_default, {
'validator': {
'test': validator,
'message': error_msg
},
})
return {
'id': action.option_strings[0] if action.option_strings else action.dest,
'type': widget,
'cli_type': choose_cli_type(action),
'required': action.required,
'data': {
'display_name': action.metavar or action.dest,
'help': action.help,
'required': action.required,
'nargs': action.nargs or '',
def build_app(build_spec):
app = wx.App(False)
i18n.load(build_spec['language_dir'], build_spec['language'], build_spec['encoding'])
imagesPaths = image_repository.loadImages(build_spec['image_dir'])
gapp = GooeyApplication(merge(build_spec, imagesPaths))
# wx.lib.inspection.InspectionTool().Show()
gapp.Show()
return app
def __init__(self, *args, **kwargs):
defaults = {'label': _('choose_date')}
super(DateChooser, self).__init__(*args, **merge(kwargs, defaults))
def getValue(self):
for button, widget in zip(self.radioButtons, self.widgets):
if button.GetValue(): # is Checked
return merge(widget.getValue(), {'id': self._id})
else:
# just return the first widget's value even though it's
# not active so that the expected interface is satisfied
return self.widgets[0].getValue()
def MultilineTextInput(_, parent, *args, **kwargs):
style = {'style': wx.TE_MULTILINE}
return TextInput(parent, *args, **merge(kwargs, style))
def loadImages(targetDir):
defaultImages = resolvePaths(getResourcePath('images'), filenames)
return {'images': merge(defaultImages, collectOverrides(targetDir, filenames))}