summary refs log tree commit diff
path: root/synapse/config/_base.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-02-11 17:01:38 +0000
committerErik Johnston <erik@matrix.org>2015-02-11 17:01:38 +0000
commit42bc56dad3b9ba9920d6cec364ddda8f1bc93f7e (patch)
treeb041e953b846e742438ae99de330462612273c6a /synapse/config/_base.py
parentpyflakes (diff)
parentAllow newer versions of syutil (diff)
downloadsynapse-42bc56dad3b9ba9920d6cec364ddda8f1bc93f7e.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into use-simplejson
Diffstat (limited to 'synapse/config/_base.py')
-rw-r--r--synapse/config/_base.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py
index 9b0f8c3c32..87cdbf1d30 100644
--- a/synapse/config/_base.py
+++ b/synapse/config/_base.py
@@ -28,6 +28,16 @@ class Config(object):
         pass
 
     @staticmethod
+    def parse_size(string):
+        sizes = {"K": 1024, "M": 1024 * 1024}
+        size = 1
+        suffix = string[-1]
+        if suffix in sizes:
+            string = string[:-1]
+            size = sizes[suffix]
+        return int(string) * size
+
+    @staticmethod
     def abspath(file_path):
         return os.path.abspath(file_path) if file_path else file_path