Wrap func so it's not called if its first param is None >>> print_text = pass_none(print) >>> print_text('text') text >>> print_text(None)
(func)
| 89 | |
| 90 | # From jaraco.functools 3.3 |
| 91 | def pass_none(func): |
| 92 | """ |
| 93 | Wrap func so it's not called if its first param is None |
| 94 | |
| 95 | >>> print_text = pass_none(print) |
| 96 | >>> print_text('text') |
| 97 | text |
| 98 | >>> print_text(None) |
| 99 | """ |
| 100 | |
| 101 | @functools.wraps(func) |
| 102 | def wrapper(param, *args, **kwargs): |
| 103 | if param is not None: |
| 104 | return func(param, *args, **kwargs) |
| 105 | |
| 106 | return wrapper |
| 107 | |
| 108 | |
| 109 | # From jaraco.functools 4.4 |
no outgoing calls
no test coverage detected
searching dependent graphs…