MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / Event

Class Event

src/util/Event.py:4–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2
3
4class Event(list):
5
6 def __call__(self, *args, **kwargs):
7 for f in self[:]:
8 if "once" in dir(f) and f in self:
9 self.remove(f)
10 f(*args, **kwargs)
11
12 def __repr__(self):
13 return "Event(%s)" % list.__repr__(self)
14
15 def once(self, func, name=None):
16 func.once = True
17 func.name = None
18 if name: # Dont function with same name twice
19 names = [f.name for f in self if "once" in dir(f)]
20 if name not in names:
21 func.name = name
22 self.append(func)
23 else:
24 self.append(func)
25 return self
26
27
28if __name__ == "__main__":

Callers 2

testBenchmarkFunction · 0.85
testUsageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected