From 3888915996e3d28ec9d37465ef7601765f07ab9a Mon Sep 17 00:00:00 2001
From: David-Sarah Hopwood <david-sarah@jacaranda.org>
Date: Thu, 27 Dec 2012 20:08:27 +0000
Subject: [PATCH] Make abbreviate_space able to output in exabytes. refs #1812

Signed-off-by: David-Sarah Hopwood <davidsarah@mint>
---
 src/allmydata/test/test_util.py  | 6 ++++--
 src/allmydata/util/abbreviate.py | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/allmydata/test/test_util.py b/src/allmydata/test/test_util.py
index b2d9bbec..ecaaa441 100644
--- a/src/allmydata/test/test_util.py
+++ b/src/allmydata/test/test_util.py
@@ -733,7 +733,8 @@ class Abbreviate(unittest.TestCase):
                     (1000*1000*1000, "1.00 GB"),
                     (1000*1000*1000*1000, "1.00 TB"),
                     (1000*1000*1000*1000*1000, "1.00 PB"),
-                    (1234567890123456, "1.23 PB"),
+                    (1000*1000*1000*1000*1000*1000, "1.00 EB"),
+                    (1234567890123456789, "1.23 EB"),
                     ]
         for (x, expected) in tests_si:
             got = abbreviate.abbreviate_space(x, SI=True)
@@ -753,7 +754,8 @@ class Abbreviate(unittest.TestCase):
                           (1024*1024*1024*1024, "1.00 TiB"),
                           (1000*1000*1000*1000*1000, "909.49 TiB"),
                           (1024*1024*1024*1024*1024, "1.00 PiB"),
-                          (1234567890123456, "1.10 PiB"),
+                          (1024*1024*1024*1024*1024*1024, "1.00 EiB"),
+                          (1234567890123456789, "1.07 EiB"),
                     ]
         for (x, expected) in tests_base1024:
             got = abbreviate.abbreviate_space(x, SI=False)
diff --git a/src/allmydata/util/abbreviate.py b/src/allmydata/util/abbreviate.py
index 46dda6c9..4bc17061 100644
--- a/src/allmydata/util/abbreviate.py
+++ b/src/allmydata/util/abbreviate.py
@@ -49,7 +49,9 @@ def abbreviate_space(s, SI=True):
         return r(s/(U*U*U), "G")
     if s < U*U*U*U*U:
         return r(s/(U*U*U*U), "T")
-    return r(s/(U*U*U*U*U), "P")
+    if s < U*U*U*U*U*U:
+        return r(s/(U*U*U*U*U), "P")
+    return r(s/(U*U*U*U*U*U), "E")
 
 def abbreviate_space_both(s):
     return "(%s, %s)" % (abbreviate_space(s, True),
-- 
2.45.2