config/ext: Remove ext. prefix from configs.
This commit is contained in:
parent
15d0c7a13f
commit
e226ddd652
@ -99,7 +99,7 @@ installation using ``pip install Mopidy-Something==dev`` to work.
|
|||||||
Before starting Mopidy, you must add your Soundspot username and password
|
Before starting Mopidy, you must add your Soundspot username and password
|
||||||
to the Mopidy configuration file::
|
to the Mopidy configuration file::
|
||||||
|
|
||||||
[ext.soundspot]
|
[soundspot]
|
||||||
username = alice
|
username = alice
|
||||||
password = secret
|
password = secret
|
||||||
|
|
||||||
@ -199,13 +199,13 @@ The default configuration for the extension is defined by the
|
|||||||
``get_default_config()`` method in the ``Extension`` class which returns a
|
``get_default_config()`` method in the ``Extension`` class which returns a
|
||||||
:mod:`ConfigParser` compatible config section. The config section's name should
|
:mod:`ConfigParser` compatible config section. The config section's name should
|
||||||
be the same as the extension's short name, as defined in the ``entry_points``
|
be the same as the extension's short name, as defined in the ``entry_points``
|
||||||
part of ``setup.py``, but prefixed with ``ext.``, for example
|
part of ``setup.py``, for example ``soundspot``. All extensions should include
|
||||||
``ext.soundspot``. All extensions should include an ``enabled`` config which
|
an ``enabled`` config which should default to ``true``. Provide good defaults
|
||||||
should default to ``true``. Provide good defaults for all config values so that
|
for all config values so that as few users as possible will need to change
|
||||||
as few users as possible will need to change them. The exception is if the
|
them. The exception is if the config value has security implications; in that
|
||||||
config value has security implications; in that case you should default to the
|
case you should default to the most secure configuration. Leave any
|
||||||
most secure configuration. Leave any configurations that doesn't have
|
configurations that doesn't have meaningful defaults blank, like ``username``
|
||||||
meaningful defaults blank, like ``username`` and ``password``.
|
and ``password``.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ meaningful defaults blank, like ``username`` and ``password``.
|
|||||||
__version__ = '0.1'
|
__version__ = '0.1'
|
||||||
|
|
||||||
default_config = """
|
default_config = """
|
||||||
[ext.soundspot]
|
[soundspot]
|
||||||
enabled = true
|
enabled = true
|
||||||
username =
|
username =
|
||||||
password =
|
password =
|
||||||
|
|||||||
@ -194,11 +194,11 @@ def load_extensions():
|
|||||||
logger.debug(
|
logger.debug(
|
||||||
'Loaded extension: %s %s', extension.dist_name, extension.version)
|
'Loaded extension: %s %s', extension.dist_name, extension.version)
|
||||||
|
|
||||||
if entry_point.name != extension.name:
|
if entry_point.name != extension.ext_name:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'Disabled extension %(ep)s: entry point name (%(ep)s) '
|
'Disabled extension %(ep)s: entry point name (%(ep)s) '
|
||||||
'does not match extension name (%(ext)s)',
|
'does not match extension name (%(ext)s)',
|
||||||
{'ep': entry_point.name, 'ext': extension.name})
|
{'ep': entry_point.name, 'ext': extension.ext_name})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -210,7 +210,7 @@ def load_extensions():
|
|||||||
|
|
||||||
extensions.append(extension)
|
extensions.append(extension)
|
||||||
|
|
||||||
names = (e.name for e in extensions)
|
names = (e.ext_name for e in extensions)
|
||||||
logging.info('Found following runnable extensions: %s', ', '.join(names))
|
logging.info('Found following runnable extensions: %s', ', '.join(names))
|
||||||
return extensions
|
return extensions
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ def filter_enabled_extensions(raw_config, extensions):
|
|||||||
if boolean.deserialize(enabled):
|
if boolean.deserialize(enabled):
|
||||||
filtered_extensions.append(extension)
|
filtered_extensions.append(extension)
|
||||||
|
|
||||||
names = (e.name for e in filtered_extensions)
|
names = (e.ext_name for e in filtered_extensions)
|
||||||
logging.info('Following extensions will be started: %s', ', '.join(names))
|
logging.info('Following extensions will be started: %s', ', '.join(names))
|
||||||
return filtered_extensions
|
return filtered_extensions
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from mopidy.utils import config, formatting
|
|||||||
|
|
||||||
|
|
||||||
default_config = """
|
default_config = """
|
||||||
[ext.local]
|
[local]
|
||||||
|
|
||||||
# If the local extension should be enabled or not
|
# If the local extension should be enabled or not
|
||||||
enabled = true
|
enabled = true
|
||||||
@ -47,7 +47,7 @@ None
|
|||||||
class Extension(ext.Extension):
|
class Extension(ext.Extension):
|
||||||
|
|
||||||
dist_name = 'Mopidy-Local'
|
dist_name = 'Mopidy-Local'
|
||||||
name = 'local'
|
ext_name = 'local'
|
||||||
version = mopidy.__version__
|
version = mopidy.__version__
|
||||||
|
|
||||||
def get_default_config(self):
|
def get_default_config(self):
|
||||||
|
|||||||
@ -7,7 +7,7 @@ from mopidy.utils import config, formatting
|
|||||||
|
|
||||||
|
|
||||||
default_config = """
|
default_config = """
|
||||||
[ext.spotify]
|
[spotify]
|
||||||
|
|
||||||
# If the Spotify extension should be enabled or not
|
# If the Spotify extension should be enabled or not
|
||||||
enabled = true
|
enabled = true
|
||||||
@ -68,7 +68,7 @@ https://github.com/mopidy/mopidy/issues?labels=Spotify+backend
|
|||||||
class Extension(ext.Extension):
|
class Extension(ext.Extension):
|
||||||
|
|
||||||
dist_name = 'Mopidy-Spotify'
|
dist_name = 'Mopidy-Spotify'
|
||||||
name = 'spotify'
|
ext_name = 'spotify'
|
||||||
version = mopidy.__version__
|
version = mopidy.__version__
|
||||||
|
|
||||||
def get_default_config(self):
|
def get_default_config(self):
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from mopidy.utils import config, formatting
|
|||||||
|
|
||||||
|
|
||||||
default_config = """
|
default_config = """
|
||||||
[ext.stream]
|
[stream]
|
||||||
|
|
||||||
# If the stream extension should be enabled or not
|
# If the stream extension should be enabled or not
|
||||||
enabled = true
|
enabled = true
|
||||||
@ -46,7 +46,7 @@ None
|
|||||||
class Extension(ext.Extension):
|
class Extension(ext.Extension):
|
||||||
|
|
||||||
dist_name = 'Mopidy-Stream'
|
dist_name = 'Mopidy-Stream'
|
||||||
name = 'stream'
|
ext_name = 'stream'
|
||||||
version = mopidy.__version__
|
version = mopidy.__version__
|
||||||
|
|
||||||
def get_default_config(self):
|
def get_default_config(self):
|
||||||
|
|||||||
@ -6,15 +6,9 @@ from mopidy.utils import config
|
|||||||
class Extension(object):
|
class Extension(object):
|
||||||
|
|
||||||
dist_name = None
|
dist_name = None
|
||||||
name = None
|
ext_name = None
|
||||||
version = None
|
version = None
|
||||||
|
|
||||||
@property
|
|
||||||
def ext_name(self):
|
|
||||||
if self.name is None:
|
|
||||||
return None
|
|
||||||
return 'ext.%s' % self.name
|
|
||||||
|
|
||||||
def get_default_config(self):
|
def get_default_config(self):
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
'Add at least a config section with "enabled = true"')
|
'Add at least a config section with "enabled = true"')
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from mopidy.utils import config, formatting
|
|||||||
|
|
||||||
|
|
||||||
default_config = """
|
default_config = """
|
||||||
[ext.http]
|
[http]
|
||||||
|
|
||||||
# If the HTTP extension should be enabled or not
|
# If the HTTP extension should be enabled or not
|
||||||
enabled = true
|
enabled = true
|
||||||
@ -520,7 +520,7 @@ Example to get started with
|
|||||||
class Extension(ext.Extension):
|
class Extension(ext.Extension):
|
||||||
|
|
||||||
dist_name = 'Mopidy-HTTP'
|
dist_name = 'Mopidy-HTTP'
|
||||||
name = 'http'
|
ext_name = 'http'
|
||||||
version = mopidy.__version__
|
version = mopidy.__version__
|
||||||
|
|
||||||
def get_default_config(self):
|
def get_default_config(self):
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from mopidy.utils import config, formatting
|
|||||||
|
|
||||||
|
|
||||||
default_config = """
|
default_config = """
|
||||||
[ext.lastfm]
|
[lastfm]
|
||||||
|
|
||||||
# If the Last.fm extension should be enabled or not
|
# If the Last.fm extension should be enabled or not
|
||||||
enabled = true
|
enabled = true
|
||||||
@ -45,7 +45,7 @@ The frontend is enabled by default if all dependencies are available.
|
|||||||
class Extension(ext.Extension):
|
class Extension(ext.Extension):
|
||||||
|
|
||||||
dist_name = 'Mopidy-Lastfm'
|
dist_name = 'Mopidy-Lastfm'
|
||||||
name = 'lastfm'
|
ext_name = 'lastfm'
|
||||||
version = mopidy.__version__
|
version = mopidy.__version__
|
||||||
|
|
||||||
def get_default_config(self):
|
def get_default_config(self):
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from mopidy.utils import config, formatting
|
|||||||
|
|
||||||
|
|
||||||
default_config = """
|
default_config = """
|
||||||
[ext.mpd]
|
[mpd]
|
||||||
|
|
||||||
# If the MPD extension should be enabled or not
|
# If the MPD extension should be enabled or not
|
||||||
enabled = true
|
enabled = true
|
||||||
@ -89,7 +89,7 @@ near future:
|
|||||||
class Extension(ext.Extension):
|
class Extension(ext.Extension):
|
||||||
|
|
||||||
dist_name = 'Mopidy-MPD'
|
dist_name = 'Mopidy-MPD'
|
||||||
name = 'mpd'
|
ext_name = 'mpd'
|
||||||
version = mopidy.__version__
|
version = mopidy.__version__
|
||||||
|
|
||||||
def get_default_config(self):
|
def get_default_config(self):
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from mopidy.utils import formatting, config
|
|||||||
|
|
||||||
|
|
||||||
default_config = """
|
default_config = """
|
||||||
[ext.mpris]
|
[mpris]
|
||||||
|
|
||||||
# If the MPRIS extension should be enabled or not
|
# If the MPRIS extension should be enabled or not
|
||||||
enabled = true
|
enabled = true
|
||||||
@ -71,7 +71,7 @@ Now you can control Mopidy through the player object. Examples:
|
|||||||
class Extension(ext.Extension):
|
class Extension(ext.Extension):
|
||||||
|
|
||||||
dist_name = 'Mopidy-MPRIS'
|
dist_name = 'Mopidy-MPRIS'
|
||||||
name = 'mpris'
|
ext_name = 'mpris'
|
||||||
version = mopidy.__version__
|
version = mopidy.__version__
|
||||||
|
|
||||||
def get_default_config(self):
|
def get_default_config(self):
|
||||||
|
|||||||
@ -263,8 +263,7 @@ class ConfigSchema(object):
|
|||||||
class ExtensionConfigSchema(ConfigSchema):
|
class ExtensionConfigSchema(ConfigSchema):
|
||||||
"""Sub-classed :class:`ConfigSchema` for use in extensions.
|
"""Sub-classed :class:`ConfigSchema` for use in extensions.
|
||||||
|
|
||||||
Ensures that `enabled` config value is present and that section name is
|
Ensures that `enabled` config value is present.
|
||||||
prefixed with ext.
|
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ExtensionConfigSchema, self).__init__()
|
super(ExtensionConfigSchema, self).__init__()
|
||||||
|
|||||||
@ -13,16 +13,9 @@ class ExtensionTest(unittest.TestCase):
|
|||||||
def test_dist_name_is_none(self):
|
def test_dist_name_is_none(self):
|
||||||
self.assertIsNone(self.ext.dist_name)
|
self.assertIsNone(self.ext.dist_name)
|
||||||
|
|
||||||
def test_name_is_none(self):
|
|
||||||
self.assertIsNone(self.ext.name)
|
|
||||||
|
|
||||||
def test_ext_name_is_none(self):
|
def test_ext_name_is_none(self):
|
||||||
self.assertIsNone(self.ext.ext_name)
|
self.assertIsNone(self.ext.ext_name)
|
||||||
|
|
||||||
def test_ext_name_prefixes_ext(self):
|
|
||||||
self.ext.name = 'foo'
|
|
||||||
self.assertEqual('ext.foo', self.ext.ext_name)
|
|
||||||
|
|
||||||
def test_version_is_none(self):
|
def test_version_is_none(self):
|
||||||
self.assertIsNone(self.ext.version)
|
self.assertIsNone(self.ext.version)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user