diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2022-05-09 10:28:14 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2022-05-10 07:47:52 -0400 |
| commit | 7e3e58ce198d9319bb2279c2da4b1f298914d8a5 (patch) | |
| tree | 1af3b0f99f5e37c47789bf93519392e08eb24094 /setuptools/_distutils/_functools.py | |
| parent | e009a87b5578cb16099b697ba8395c8f6bdd70f3 (diff) | |
| parent | a7cfb56a7b1eaa95824d81a34e8e70b85d42f784 (diff) | |
| download | python-setuptools-git-7e3e58ce198d9319bb2279c2da4b1f298914d8a5.tar.gz | |
Merge https://github.com/pypa/distutils into feature/distutils-a7cfb56a7b1eaa
Diffstat (limited to 'setuptools/_distutils/_functools.py')
| -rw-r--r-- | setuptools/_distutils/_functools.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/setuptools/_distutils/_functools.py b/setuptools/_distutils/_functools.py new file mode 100644 index 00000000..e7053bac --- /dev/null +++ b/setuptools/_distutils/_functools.py @@ -0,0 +1,20 @@ +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 |
