1
0
Fork 0
forked from bton/matekasse
matekasse/venv/lib/python3.11/site-packages/setuptools/_distutils/_functools.py

21 lines
411 B
Python
Raw Normal View History

2023-07-28 21:30:45 +00:00
import functools
# from jaraco.functools 3.5
def pass_none(func):
"""
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)
"""
@functools.wraps(func)
def wrapper(param, *args, **kwargs):
if param is not None:
return func(param, *args, **kwargs)
return wrapper