summaryrefslogtreecommitdiffstats
path: root/third_party/python/setuptools/setuptools/_distutils/_functools.py
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/python/setuptools/setuptools/_distutils/_functools.py')
-rw-r--r--third_party/python/setuptools/setuptools/_distutils/_functools.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/third_party/python/setuptools/setuptools/_distutils/_functools.py b/third_party/python/setuptools/setuptools/_distutils/_functools.py
new file mode 100644
index 0000000000..e7053bac12
--- /dev/null
+++ b/third_party/python/setuptools/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