Add Timers.find_all, to find all timers of a certain name
This commit is contained in:
parent
1d206fe78f
commit
7704de25b6
1 changed files with 10 additions and 0 deletions
|
@ -91,6 +91,16 @@ class Timers(object):
|
||||||
def get_timers(self) -> typing.List[Timer]:
|
def get_timers(self) -> typing.List[Timer]:
|
||||||
return self.timers + sum(self.context_timers.values(), [])
|
return self.timers + sum(self.context_timers.values(), [])
|
||||||
|
|
||||||
|
def find_all(self, name: str) -> typing.List[Timer]:
|
||||||
|
name_lower = name.lower()
|
||||||
|
timers = self.get_timers()
|
||||||
|
found = [] # type: typing.List[Timer]
|
||||||
|
for timer in timers:
|
||||||
|
if timer.name.lower() == name_lower:
|
||||||
|
found.append(timer)
|
||||||
|
|
||||||
|
return found
|
||||||
|
|
||||||
def call(self):
|
def call(self):
|
||||||
for timer in self.get_timers():
|
for timer in self.get_timers():
|
||||||
if timer.due():
|
if timer.due():
|
||||||
|
|
Loading…
Reference in a new issue