You must now use 'eval' to get the body of a concept
This commit is contained in:
@@ -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__
|
||||
|
||||
Reference in New Issue
Block a user