config: Add read helper
This commit is contained in:
parent
917c1e4c9d
commit
b655e846b1
@ -14,7 +14,7 @@ class Extension(ext.Extension):
|
||||
|
||||
def get_default_config(self):
|
||||
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
|
||||
return open(conf_file).read()
|
||||
return config.read(conf_file)
|
||||
|
||||
def get_config_schema(self):
|
||||
schema = config.ExtensionConfigSchema()
|
||||
|
||||
@ -14,7 +14,7 @@ class Extension(ext.Extension):
|
||||
|
||||
def get_default_config(self):
|
||||
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
|
||||
return open(conf_file).read()
|
||||
return config.read(conf_file)
|
||||
|
||||
def get_config_schema(self):
|
||||
schema = config.ExtensionConfigSchema()
|
||||
|
||||
@ -14,7 +14,7 @@ class Extension(ext.Extension):
|
||||
|
||||
def get_default_config(self):
|
||||
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
|
||||
return open(conf_file).read()
|
||||
return config.read(conf_file)
|
||||
|
||||
def get_config_schema(self):
|
||||
schema = config.ExtensionConfigSchema()
|
||||
|
||||
@ -35,10 +35,15 @@ config_schemas['proxy']['password'] = String(optional=True, secret=True)
|
||||
#config_schemas['audio.outputs'] = config.AudioOutputConfigSchema()
|
||||
|
||||
|
||||
def read(config_file):
|
||||
"""Helper to load defaults in same way across core and extensions."""
|
||||
with io.open(config_file, 'rb') as filehandle:
|
||||
return filehandle.read()
|
||||
|
||||
|
||||
def load(files, overrides, extensions=None):
|
||||
default_config_file = os.path.join(
|
||||
os.path.dirname(__file__), 'default.conf')
|
||||
defaults = [open(default_config_file).read()]
|
||||
config_dir = os.path.dirname(__file__)
|
||||
defaults = [read(os.path.join(config_dir, 'default.conf'))]
|
||||
if extensions:
|
||||
defaults.extend(e.get_default_config() for e in extensions)
|
||||
return _load(files, defaults, overrides)
|
||||
|
||||
@ -14,7 +14,7 @@ class Extension(ext.Extension):
|
||||
|
||||
def get_default_config(self):
|
||||
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
|
||||
return open(conf_file).read()
|
||||
return config.read(conf_file)
|
||||
|
||||
def get_config_schema(self):
|
||||
schema = config.ExtensionConfigSchema()
|
||||
|
||||
@ -14,7 +14,7 @@ class Extension(ext.Extension):
|
||||
|
||||
def get_default_config(self):
|
||||
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
|
||||
return open(conf_file).read()
|
||||
return config.read(conf_file)
|
||||
|
||||
def get_config_schema(self):
|
||||
schema = config.ExtensionConfigSchema()
|
||||
|
||||
@ -14,7 +14,7 @@ class Extension(ext.Extension):
|
||||
|
||||
def get_default_config(self):
|
||||
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
|
||||
return open(conf_file).read()
|
||||
return config.read(conf_file)
|
||||
|
||||
def get_config_schema(self):
|
||||
schema = config.ExtensionConfigSchema()
|
||||
|
||||
@ -14,7 +14,7 @@ class Extension(ext.Extension):
|
||||
|
||||
def get_default_config(self):
|
||||
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
|
||||
return open(conf_file).read()
|
||||
return config.read(conf_file)
|
||||
|
||||
def get_config_schema(self):
|
||||
schema = config.ExtensionConfigSchema()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user