summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-09-01 20:44:43 +0100
committerMark Haines <mark.haines@matrix.org>2014-09-01 20:44:51 +0100
commit6fd730c96b9c9675db4144de16c255b9a43d169e (patch)
tree603ab35e6f1bed0ece4901e41b29d4dfea44f0d3
parentDon't set a 'default' key in the creation event (diff)
downloadsynapse-6fd730c96b9c9675db4144de16c255b9a43d169e.tar.xz
Use yaml for config file
-rw-r--r--synapse/config/_base.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py
index 78197e4a75..08de6ee5ec 100644
--- a/synapse/config/_base.py
+++ b/synapse/config/_base.py
@@ -18,6 +18,7 @@ import ConfigParser as configparser
 import argparse
 import sys
 import os
+import yaml
 
 
 class Config(object):
@@ -35,12 +36,8 @@ class Config(object):
 
     @staticmethod
     def read_config_file(file_path):
-        config = configparser.SafeConfigParser()
-        config.read([file_path])
-        config_dict = {}
-        for section in config.sections():
-            config_dict.update(config.items(section))
-        return config_dict
+        with open(file_path) as file_stream:
+            return yaml.load(file_stream)
 
     @classmethod
     def add_arguments(cls, parser):
@@ -95,15 +92,13 @@ class Config(object):
             config_dir_path = os.path.dirname(config_args.config_path)
             config_dir_path = os.path.abspath(config_dir_path)
             cls.generate_config(args, config_dir_path)
-            config = configparser.SafeConfigParser()
-            config.add_section(generate_section)
+            config = {}
             for key, value in vars(args).items():
                 if (key not in set(["config_path", "generate_config"])
                     and value is not None):
-                    print key, "=", value
-                    config.set(generate_section, key, str(value))
+                    config[key] = value
             with open(config_args.config_path, "w") as config_file:
-                config.write(config_file)
+                yaml.dump(config, config_file, default_flow_style=False)
             sys.exit(0)
 
         return cls(args)