piccal/result.py

35 lines
698 B
Python
Raw Normal View History

2019-08-20 01:18:57 +00:00
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