mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-07-06 04:52:14 -07:00
code release
This commit is contained in:
parent
b941ba41a3
commit
a902f11f74
354 changed files with 826570 additions and 1 deletions
24
xlib/python/EventListener.py
Normal file
24
xlib/python/EventListener.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
from collections import Iterable
|
||||
|
||||
|
||||
class EventListener:
|
||||
__slots__ = ['_funcs']
|
||||
def __init__(self):
|
||||
self._funcs = []
|
||||
|
||||
def has_listeners(self):
|
||||
return len(self._funcs) != 0
|
||||
|
||||
def add(self, func_or_list):
|
||||
if isinstance(func_or_list, Iterable):
|
||||
func_or_list = tuple(func_or_list)
|
||||
else:
|
||||
func_or_list = (func_or_list,)
|
||||
|
||||
for func in func_or_list:
|
||||
if func not in self._funcs:
|
||||
self._funcs.append(func)
|
||||
|
||||
def call(self, *args, **kwargs):
|
||||
for func in self._funcs:
|
||||
func(*args, **kwargs)
|
Loading…
Add table
Add a link
Reference in a new issue