diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2014-12-11 18:35:05 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2014-12-11 18:35:05 +0000 |
commit | 0b700233737adfa3c6558e988822e7f9ee31ca39 (patch) | |
tree | eac8aff9fb9f58da245c9c3e7a80fa13ac5e1eb1 /synapse/config/_base.py | |
parent | Merge remote-tracking branch 'origin' into typing_notifications (diff) | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into develop (diff) | |
download | synapse-0b700233737adfa3c6558e988822e7f9ee31ca39.tar.xz |
Merge branch 'develop' into typing_notifications
Diffstat (limited to 'synapse/config/_base.py')
-rw-r--r-- | synapse/config/_base.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py index 6870af10e8..1426436dcb 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) |