picadae calibration programs
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.

result.py 845B

123456789101112131415161718192021222324252627282930313233343536
  1. ##| Copyright: (C) 2019-2020 Kevin Larke <contact AT larke DOT org>
  2. ##| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
  3. import json
  4. class Result(object):
  5. def __init__( self, value=None, msg=None ):
  6. self.value = value
  7. self.msg = msg
  8. self.resultL = []
  9. def set_error( self, msg ):
  10. if self.msg is None:
  11. self.msg = ""
  12. self.msg += " " + msg
  13. def print(self):
  14. if value:
  15. print(value)
  16. if msg:
  17. print(msg)
  18. if resultL:
  19. print(resultL)
  20. def __bool__( self ):
  21. return self.msg is None
  22. def __iadd__( self, b ):
  23. if self.value is None and self.msg is None:
  24. self = b
  25. else:
  26. self.resultL.append(b)
  27. return self