piccal/result.py
2019-08-19 21:18:57 -04:00

35 lines
698 B
Python

import json
class Result(object):
def __init__( self, value=None, msg=None ):
self.value = value
self.msg = msg
self.resultL = []
def set_error( self, msg ):
if self.msg is None:
self.msg = ""
self.msg += " " + msg
def print(self):
if value:
print(value)
if msg:
print(msg)
if resultL:
print(resultL)
def __bool__( self ):
return self.msg is None
def __iadd__( self, b ):
if self.value is None and self.msg is None:
self = b
else:
self.resultL.append(b)
return self