From 27fe66a83c453b9e17ff065fbc6d779fcec38f4c Mon Sep 17 00:00:00 2001 From: Matt Mackall Date: Thu, 26 May 2011 09:17:28 -0500 Subject: [PATCH] Add support for terabytes --- smem | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/smem b/smem index c09c134..9c3cb23 100755 --- a/smem +++ b/smem @@ -176,7 +176,7 @@ def units(x): s = '' if x == 0: return '0' - for s in ('', 'K', 'M', 'G'): + for s in ('', 'K', 'M', 'G', 'T'): if x < 1024: break x /= 1024.0 @@ -184,7 +184,8 @@ def units(x): def fromunits(x): s = dict(k=2**10, K=2**10, kB=2**10, KB=2**10, - M=2**20, MB=2**20, G=2**30, GB=2**30) + M=2**20, MB=2**20, G=2**30, GB=2**30, + T=2**40, TB=2**40) for k,v in s.items(): if x.endswith(k): return int(float(x[:-len(k)])*v)