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.

70 lines
1.4 KiB

'''
Created on Jan 23, 2014
@author: Chris
'''
import sys
from gooey.monkey_parser import ArgumentError
from gooey.gui.action_sorter import ActionSorter
class ClientApp(object):
def __init__(self, parser, payload):
self._parser = parser
self.description = parser.description
self.action_groups = ActionSorter(self._parser._actions)
self.payload = payload
def HasPositionals(self):
if self.action_groups._positionals:
return True
return False
def IsValidArgString(self, arg_string):
if isinstance(self._Parse(arg_string), str):
return False
return True
def _Parse(self, arg_string):
try:
print self._parser.error
self._parser.parse_args(arg_string.split())
return True
except ArgumentError as e:
return str(e)
def GetErrorMsg(self, arg_string):
return self._FormatMsg(self._Parse(arg_string))
def _FormatMsg(self, msg):
output = list(msg)
if ':' in output:
output[output.index(':')] = ':\n '
return ''.join(output)
def AddToArgv(self, arg_string):
sys.argv.extend(arg_string.split())
class EmptyClientApp(object):
def __init__(self):
'''
initializes a BlankModel object
As you can see. This class does nothing..
'''
self.description = ''
if __name__ == '__main__':
pass
# print m2