diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-09-18 18:00:59 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-09-18 18:00:59 -0700 |
commit | 848a7209e29d580594d35f299b01db97714caf92 (patch) | |
tree | 57425aa20493dccc62bc95e59268fde66eeb368f /paramiko/util.py | |
parent | 6ee3f1a074d2b13cca2a5d267f16159f294b98c6 (diff) | |
parent | 16a8df33eb4e9723fea244959db2b157be825781 (diff) | |
download | paramiko-848a7209e29d580594d35f299b01db97714caf92.tar.gz |
Merge branch 'master' into switch-to-cryptography
Conflicts:
paramiko/ecdsakey.py
tests/test_client.py
Diffstat (limited to 'paramiko/util.py')
-rw-r--r-- | paramiko/util.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/paramiko/util.py b/paramiko/util.py index f966099d..25062d00 100644 --- a/paramiko/util.py +++ b/paramiko/util.py @@ -290,5 +290,14 @@ def constant_time_bytes_eq(a, b): 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)) |