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 | 70f669a0a41e104bd0427e8ad9142071aae241ed (patch) | |
tree | a5c0a22c336514e1db001012a64d15477986b671 /paramiko/util.py | |
parent | e9306cab7448e641a54789039f5c8bfe988de320 (diff) | |
parent | ccd643cdbd7ba752727d62051058a4454451414d (diff) | |
download | python-paramiko-70f669a0a41e104bd0427e8ad9142071aae241ed.tar python-paramiko-70f669a0a41e104bd0427e8ad9142071aae241ed.tar.gz |
Merge tag 'upstream/1.15.0'
Upstream version 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)) |