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.

63 lines
1.3 KiB

  1. '''
  2. Created on Jan 23, 2014
  3. @author: Chris
  4. '''
  5. import sys
  6. from gooey.gui.action_sorter import ActionSorter
  7. class ClientApp(object):
  8. def __init__(self, parser, payload):
  9. self._parser = parser
  10. self.description = parser.description
  11. self.action_groups = ActionSorter(self._parser._actions)
  12. self.payload = payload
  13. def HasPositionals(self):
  14. if self.action_groups._positionals:
  15. return True
  16. return False
  17. def IsValidArgString(self, arg_string):
  18. if isinstance(self._Parse(arg_string), str):
  19. return False
  20. return True
  21. def _Parse(self, arg_string):
  22. try:
  23. self._parser.parse_args(arg_string.split())
  24. return True
  25. except Exception as e:
  26. return str(e)
  27. def GetErrorMsg(self, arg_string):
  28. return self._FormatMsg(self._Parse(arg_string))
  29. def _FormatMsg(self, msg):
  30. output = list(msg)
  31. if ':' in output:
  32. output[output.index(':')] = ':\n '
  33. return ''.join(output)
  34. def AddToArgv(self, arg_string):
  35. sys.argv.extend(arg_string.split())
  36. class EmptyClientApp(object):
  37. def __init__(self, payload):
  38. '''
  39. initializes a BlankModel object
  40. As you can see. This class does nothing..
  41. '''
  42. self.description = ''
  43. self.payload = payload
  44. if __name__ == '__main__':
  45. pass