summary refs log tree commit diff
path: root/synapse/config/_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/config/_base.py')
-rw-r--r--synapse/config/_base.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py
index 846570811f..1cdd03e414 100644
--- a/synapse/config/_base.py
+++ b/synapse/config/_base.py
@@ -50,6 +50,16 @@ class Config(object):
             )
         return cls.abspath(file_path)
 
+    @staticmethod
+    def ensure_directory(dir_path):
+        if not os.path.exists(dir_path):
+            os.makedirs(dir_path)
+        if not os.path.isdir(dir_path):
+            raise ConfigError(
+                "%s is not a directory" % (dir_path,)
+            )
+        return dir_path
+
     @classmethod
     def read_file(cls, file_path, config_name):
         cls.check_file(file_path, config_name)
@@ -57,6 +67,10 @@ class Config(object):
             return file_stream.read()
 
     @staticmethod
+    def default_path(name):
+        return os.path.abspath(os.path.join(os.path.curdir, name))
+
+    @staticmethod
     def read_config_file(file_path):
         with open(file_path) as file_stream:
             return yaml.load(file_stream)