import os from gooey.gui.util.quoting import quote def checkbox(metadata, value): return metadata['commands'][0] if value else None def radioGroup(metadata, value): # TODO try: return self.commands[self._value.index(True)][0] except ValueError: return None def multiFileChooser(metadata, value): paths = ' '.join(quote(x) for x in value.split(os.pathsep) if x) if metadata['commands'] and paths: return u'{} {}'.format(metadata['commands'][0], paths) return paths or None def textArea(metadata, value): if metadata['commands'] and value: return '{} {}'.format(metadata['commands'][0], quote(value.encode('unicode_escape'))) else: return quote(value.encode('unicode_escape')) if value else '' def commandField(metadata, value): if metadata['commands'] and value: return u'{} {}'.format(metadata['commands'][0], value) else: return value or None def counter(metatdata, value): ''' Returns str(option_string * DropDown Value) e.g. -vvvvv ''' if not str(value).isdigit(): return None arg = str(metatdata['commands'][0]).replace('-', '') repeated_args = arg * int(value) return '-' + repeated_args def dropdown(metadata, value): if value == 'Select Option': return None elif metadata['commands'] and value: return u'{} {}'.format(metadata['commands'][0], quote(value)) else: return quote(value) if value else '' def general(metadata, value): if metadata['commands'] and value: if not metadata['nargs']: v = quote(value) else: v = value return u'{0} {1}'.format(metadata['commands'][0], v) else: if not value: return None elif not metadata['nargs']: return quote(value) else: return value