You must now use 'eval' to get the body of a concept

This commit is contained in:
2019-12-24 16:58:09 +01:00
parent 5c90b07e1a
commit 44e4b75cf8
37 changed files with 1003 additions and 383 deletions
+12 -2
View File
@@ -25,21 +25,31 @@ class Event(object):
Class that represents something that modifies the state of the system
"""
def __init__(self, message="", user="kodjo", date=datetime.now()):
def __init__(self, message="", user="", date=datetime.now()):
self.version = 1
self.user = user
self.date = date
self.message = message
self._digest = None
def get_digest(self):
"""
Returns the digest of the event
:return: hexa form of the sha256
"""
if self._digest:
return self._digest
if self.message == "" and self.user == "":
self._digest = "xxx" # to speed unit tests
return self._digest
if not isinstance(self.message, str):
raise NotImplementedError
return hashlib.sha256(f"Event:{self.user}{self.date}{self.message}".encode("utf-8")).hexdigest()
self._digest = hashlib.sha256(f"Event:{self.user}{self.date}{self.message}".encode("utf-8")).hexdigest()
return self._digest
def to_dict(self):
return self.__dict__