Total Complexity | 3 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import functools |
||
2 | |||
3 | from .. import destructure |
||
4 | |||
5 | |||
6 | def decorate(matchers, structure): |
||
7 | destructure.names(structure) # Raise ValueError if there are duplicates |
||
8 | |||
9 | def decorator(func): |
||
10 | matchers.append((structure, func)) |
||
11 | return func |
||
12 | return decorator |
||
13 | |||
14 | |||
15 | class Descriptor: |
||
16 | """Base class for decorator classes.""" |
||
17 | |||
18 | __wrapped__ = None |
||
19 | |||
20 | def __new__(cls, func, *args, **kwargs): |
||
21 | new = super().__new__(cls, *args, **kwargs) |
||
22 | new.__doc__ = None |
||
23 | if func is None: |
||
24 | return new |
||
25 | return functools.wraps(func)(new) |
||
26 |