Total Complexity | 5 |
Total Lines | 19 |
Duplicated Lines | 0 % |
1 | """ |
||
10 | try: |
||
11 | value = sentinel._cache[name] # memoized |
||
12 | except KeyError: |
||
13 | pass |
||
14 | else: |
||
15 | if doc == value.__doc__: |
||
16 | return value |
||
17 | |||
18 | raise ValueError( |
||
19 | 'attempted to create sentinel with a used name and a different' |
||
20 | ' docstring: %r\noriginal docstring:\n%s' % (name, value.__doc__), |
||
21 | ) |
||
22 | |||
23 | @object.__new__ # bind a single instance to the name 'Sentinel' |
||
24 | class Sentinel(object): |
||
25 | __doc__ = doc |
||
26 | __slots__ = ('__weakref__',) |
||
27 | __name__ = name |
||
28 | |||
29 | def __new__(cls): |
||
55 |