diff options
author | Jeremy T. Bouse <jbouse@debian.org> | 2014-09-22 09:21:39 -0400 |
---|---|---|
committer | Jeremy T. Bouse <jbouse@debian.org> | 2014-09-22 09:21:39 -0400 |
commit | ccd643cdbd7ba752727d62051058a4454451414d (patch) | |
tree | 9bc89a6629132f474b3297735069d025145a965c /paramiko/util.py | |
parent | 588a4823436454e8968ee36ae95ff92e1cddc3f7 (diff) | |
download | python-paramiko-ccd643cdbd7ba752727d62051058a4454451414d.tar python-paramiko-ccd643cdbd7ba752727d62051058a4454451414d.tar.gz |
Imported Upstream version 1.15.0upstream/1.15.0
Diffstat (limited to 'paramiko/util.py')
-rw-r--r-- | paramiko/util.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/paramiko/util.py b/paramiko/util.py index f4ee3ad..88ca2bc 100644 --- a/paramiko/util.py +++ b/paramiko/util.py @@ -320,3 +320,15 @@ def constant_time_bytes_eq(a, b): for i in (xrange if PY2 else range)(len(a)): res |= byte_ord(a[i]) ^ byte_ord(b[i]) return res == 0 + + +class ClosingContextManager(object): + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + self.close() + + +def clamp_value(minimum, val, maximum): + return max(minimum, min(val, maximum)) |