fix: added assertion error message
This commit is contained in:
@@ -24,7 +24,7 @@ class ActionFlow:
|
|||||||
def do(self, action: type[Action]):
|
def do(self, action: type[Action]):
|
||||||
name = action.__name__
|
name = action.__name__
|
||||||
index = self.indices.get(name)
|
index = self.indices.get(name)
|
||||||
assert index is not None
|
assert index is not None, "Action '%s' is not registered" % name
|
||||||
|
|
||||||
if self.on[index]: raise Unavailable(name)
|
if self.on[index]: raise Unavailable(name)
|
||||||
if self.on[index] is None: raise NotAllowed(name)
|
if self.on[index] is None: raise NotAllowed(name)
|
||||||
@@ -40,7 +40,7 @@ class ActionFlow:
|
|||||||
def index(self, action: type[Action]) -> int:
|
def index(self, action: type[Action]) -> int:
|
||||||
name = action.__name__
|
name = action.__name__
|
||||||
index = self.indices.get(name)
|
index = self.indices.get(name)
|
||||||
assert index is not None
|
assert index is not None, "Action '%s' is not registered" % name
|
||||||
return index
|
return index
|
||||||
|
|
||||||
def allow(self, action: type[Action], value=True):
|
def allow(self, action: type[Action], value=True):
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ class Timer:
|
|||||||
self.checkpoint = seconds
|
self.checkpoint = seconds
|
||||||
|
|
||||||
def pause(self):
|
def pause(self):
|
||||||
assert self.checkpoint is not None
|
assert self.checkpoint is not None, "Uninitialized"
|
||||||
self.accumulator = self.delta()
|
self.accumulator = self.delta()
|
||||||
|
|
||||||
def delta(self):
|
def delta(self):
|
||||||
assert self.checkpoint is not None
|
assert self.checkpoint is not None, "Uninitialized"
|
||||||
return floor(time()) - self.checkpoint + self.accumulator
|
return floor(time()) - self.checkpoint + self.accumulator
|
||||||
|
|||||||
Reference in New Issue
Block a user