1 def enum(*sequential, **named):
2 enums = dict(zip(sequential, range(len(sequential))), **named)
3 return type('Enum', (), enums)
12 # being a dict this can be used with json.dumps
13 class ManifoldResult (dict):
14 def __init__ (self, code=ManifoldCode.SUCCESS, value=None, output=""):
19 def from_json (self, json_string):
20 d=json.dumps(json_string)
21 for k in ['code','value','output']:
24 # this returns None if there's a problem, the value otherwise
26 if self['code']==ManifoldCode.SUCCESS:
30 return "code=%s -- %s"%(self['code'],self['output'])
34 result="[[MFresult code=%s"%self['code']
37 if isinstance(value,list): result += " [value=list with %d elts]"%len(value)
38 else: result += " [value=other %s]"%value
40 result += " [output=%s]"%self['output']