You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0 KiB

  1. import os
  2. import itertools
  3. from gooey.gui.util.quoting import quote
  4. def checkbox(metadata, value):
  5. return metadata['commands'][0] if value else None
  6. def multiFileChooser(metadata, value):
  7. paths = ' '.join(quote(x) for x in value.split(os.pathsep) if x)
  8. if metadata['commands'] and paths:
  9. return u'{} {}'.format(metadata['commands'][0], paths)
  10. return paths or None
  11. def textArea(metadata, value):
  12. if metadata['commands'] and value:
  13. return '{} {}'.format(metadata['commands'][0], quote(value.encode('unicode_escape')))
  14. else:
  15. return quote(value.encode('unicode_escape')) if value else ''
  16. def commandField(metadata, value):
  17. if metadata['commands'] and value:
  18. return u'{} {}'.format(metadata['commands'][0], value)
  19. else:
  20. return value or None
  21. def counter(metatdata, value):
  22. '''
  23. Returns
  24. str(option_string * DropDown Value)
  25. e.g.
  26. -vvvvv
  27. '''
  28. if not str(value).isdigit():
  29. return None
  30. command = str(metatdata['commands'][0]).strip()
  31. return ' '.join(itertools.repeat(command, int(value)))
  32. def dropdown(metadata, value):
  33. if value == 'Select Option':
  34. return None
  35. elif metadata['commands'] and value:
  36. return u'{} {}'.format(metadata['commands'][0], quote(value))
  37. else:
  38. return quote(value) if value else ''
  39. def listbox(meta, value):
  40. if meta['commands'] and value:
  41. return u'{} {}'.format(meta['commands'][0], ' '.join(map(quote, value)))
  42. else:
  43. return ' '.join(map(quote, value)) if value else ''
  44. def general(metadata, value):
  45. if metadata.get('commands') and value:
  46. if not metadata.get('nargs'):
  47. v = quote(value)
  48. else:
  49. v = value
  50. return u'{0} {1}'.format(metadata['commands'][0], v)
  51. else:
  52. if not value:
  53. return None
  54. elif not metadata.get('nargs'):
  55. return quote(value)
  56. else:
  57. return value