Total Complexity | 5 |
Total Lines | 19 |
Duplicated Lines | 0 % |
1 | """ |
||
10 | def sentinel(name, doc=None): |
||
11 | try: |
||
12 | value = sentinel._cache[name] # memoized |
||
13 | except KeyError: |
||
14 | pass |
||
15 | else: |
||
16 | if doc == value.__doc__: |
||
17 | return value |
||
18 | |||
19 | raise ValueError(dedent( |
||
20 | """\ |
||
21 | New sentinel value %r conflicts with an existing sentinel of the |
||
22 | same name. |
||
23 | Old sentinel docstring: %r |
||
24 | New sentinel docstring: %r |
||
25 | Resolve this conflict by changing the name of one of the sentinels. |
||
26 | """, |
||
27 | ) % (name, value.__doc__, doc)) |
||
28 | |||
29 | @object.__new__ # bind a single instance to the name 'Sentinel' |
||
61 |