ยปCore Development>Code coverage>Lib/idlelib/Delegator.py

Python code coverage for Lib/idlelib/Delegator.py

#countcontent
1n/aclass Delegator:
2n/a
3n/a # The cache is only used to be able to change delegates!
4n/a
5n/a def __init__(self, delegate=None):
6n/a self.delegate = delegate
7n/a self.__cache = set()
8n/a
9n/a def __getattr__(self, name):
10n/a attr = getattr(self.delegate, name) # May raise AttributeError
11n/a setattr(self, name, attr)
12n/a self.__cache.add(name)
13n/a return attr
14n/a
15n/a def resetcache(self):
16n/a for key in self.__cache:
17n/a try:
18n/a delattr(self, key)
19n/a except AttributeError:
20n/a pass
21n/a self.__cache.clear()
22n/a
23n/a def setdelegate(self, delegate):
24n/a self.resetcache()
25n/a self.delegate = delegate