diff options
author | Olle Lundberg <geek@nerd.sh> | 2014-08-14 15:13:58 +0200 |
---|---|---|
committer | Olle Lundberg <geek@nerd.sh> | 2014-08-14 15:16:42 +0200 |
commit | 2dec0a7671d83f21a290e1a2b3ea9159da45757a (patch) | |
tree | a6419ca78b85f19509eb9f099cecab2ad962fe62 /paramiko/util.py | |
parent | b5c537c4c88cc39323717531a46a3241eb7ca7f5 (diff) | |
download | paramiko-2dec0a7671d83f21a290e1a2b3ea9159da45757a.tar.gz |
Add a utility method for value clamping.
Diffstat (limited to 'paramiko/util.py')
-rw-r--r-- | paramiko/util.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/paramiko/util.py b/paramiko/util.py index f4ee3adc..d029f52e 100644 --- a/paramiko/util.py +++ b/paramiko/util.py @@ -320,3 +320,6 @@ 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 + +def clamp_value(minimum, val, maximum): + return max(minimum, min(val, maximum)) |