core: Add a [core] config section

I deemed it better to make core an extension (that cannot be disabled)
rather than add a special case throughout the config handling to make
it possible to have config section that doesn't belong to an extension.

This change is needed for #997.

Until #997 is completed, Mopidy will complain that core has now config
schema (because it is empty) and claim that core is disabled. This of
course has no practical effects.
This commit is contained in:
Stein Magnus Jodal 2015-07-16 21:18:12 +02:00
parent a99e161aab
commit c69c68648b
4 changed files with 28 additions and 0 deletions

View File

@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
# flake8: noqa # flake8: noqa
from .actor import Core from .actor import Core
from .ext import Extension
from .history import HistoryController from .history import HistoryController
from .library import LibraryController from .library import LibraryController
from .listener import CoreListener from .listener import CoreListener

1
mopidy/core/ext.conf Normal file
View File

@ -0,0 +1 @@
[core]

25
mopidy/core/ext.py Normal file
View File

@ -0,0 +1,25 @@
from __future__ import absolute_import, unicode_literals
import os
import mopidy
from mopidy import config, ext
class Extension(ext.Extension):
dist_name = 'Mopidy-Core'
ext_name = 'core'
version = mopidy.__version__
def get_default_config(self):
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
return config.read(conf_file)
def get_config_schema(self):
schema = super(Extension, self).get_config_schema()
del schema['enabled'] # core cannot be disabled
return schema
def setup(self, registry):
pass # core has nothing to register

View File

@ -34,6 +34,7 @@ setup(
'mopidy = mopidy.__main__:main', 'mopidy = mopidy.__main__:main',
], ],
'mopidy.ext': [ 'mopidy.ext': [
'core = mopidy.core:Extension',
'http = mopidy.http:Extension', 'http = mopidy.http:Extension',
'local = mopidy.local:Extension', 'local = mopidy.local:Extension',
'file = mopidy.file:Extension', 'file = mopidy.file:Extension',