Total Complexity | 4 |
Total Lines | 16 |
Duplicated Lines | 0 % |
Coverage | 80% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | """Inspector. |
||
10 | 6 | class _Inspector(collections.namedtuple('_Inspector', ['object', 'dict'])): |
|
11 | |||
12 | """Wrapper around objects. Provides access to protocold.""" |
||
13 | |||
14 | 6 | __slots__ = () |
|
15 | |||
16 | 6 | def __new__(cls, obj, mro): |
|
17 | 6 | dct = collections.ChainMap(*[vars(cls) for cls in mro]) |
|
18 | 6 | return super().__new__(cls, obj, dct) |
|
19 | |||
20 | 6 | def get_as_attribute(self, key): |
|
21 | """Return attribute with the given name, or raise AttributeError.""" |
||
22 | 6 | try: |
|
23 | 6 | return self.dict[key] |
|
24 | except KeyError: |
||
25 | raise AttributeError(key) |
||
26 |