Add new `include` config option.

This new option allows users to provide a list of external config files
which will be evaluated when beets starts.

This is useful for keeping private settings (e.g. API keys) out of the
main configuration file.
This commit is contained in:
David Logie 2015-09-22 15:04:18 +01:00
parent 60e225deae
commit bfc5a1b803
3 changed files with 17 additions and 0 deletions

View file

@ -779,6 +779,16 @@ class Configuration(RootView):
if os.path.isfile(filename):
self.add(ConfigSource(load_yaml(filename) or {}, filename))
try:
included_filenames = self['include'].get(list)
except NotFoundError:
included_filenames = []
for filename in included_filenames:
filename = os.path.join(self.config_dir(), filename)
if os.path.isfile(filename):
self.add(ConfigSource(load_yaml(filename) or {}, filename))
def _add_default_source(self):
"""Add the package's default configuration settings. This looks
for a YAML file located inside the package for the module

View file

@ -22,6 +22,7 @@ The new features:
trigger a "lots of music" warning. :bug:`1577`
* :doc:`/plugins/plexupdate`: A new ``library_name`` option allows you to select
which Plex library to update. :bug:`1572` :bug:`1595`
* Add new `include` config option to allow including external config files.
Fixes:

View file

@ -64,6 +64,12 @@ plugins
A space-separated list of plugin module names to load. See
:ref:`using-plugins`.
include
~~~~~~~
A space-separated list of extra configuration files to include.
Filenames are relative to the directory containing ``config.yaml``.
pluginpath
~~~~~~~~~~