diff --git a/docs/extensiondev.rst b/docs/extensiondev.rst index 71ea9ec0..b64ac3b6 100644 --- a/docs/extensiondev.rst +++ b/docs/extensiondev.rst @@ -99,7 +99,7 @@ installation using ``pip install Mopidy-Something==dev`` to work. Before starting Mopidy, you must add your Soundspot username and password to the Mopidy configuration file:: - [ext.soundspot] + [soundspot] username = alice 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 :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`` -part of ``setup.py``, but prefixed with ``ext.``, for example -``ext.soundspot``. All extensions should include an ``enabled`` config which -should default to ``true``. Provide good defaults for all config values so that -as few users as possible will need to change them. The exception is if the -config value has security implications; in that case you should default to the -most secure configuration. Leave any configurations that doesn't have -meaningful defaults blank, like ``username`` and ``password``. +part of ``setup.py``, for example ``soundspot``. All extensions should include +an ``enabled`` config which should default to ``true``. Provide good defaults +for all config values so that as few users as possible will need to change +them. The exception is if the config value has security implications; in that +case you should default to the most secure configuration. Leave any +configurations that doesn't have meaningful defaults blank, like ``username`` +and ``password``. :: @@ -225,7 +225,7 @@ meaningful defaults blank, like ``username`` and ``password``. __version__ = '0.1' default_config = """ - [ext.soundspot] + [soundspot] enabled = true username = password = diff --git a/mopidy/__main__.py b/mopidy/__main__.py index 60c0d73d..5c2f7cfd 100644 --- a/mopidy/__main__.py +++ b/mopidy/__main__.py @@ -194,11 +194,11 @@ def load_extensions(): logger.debug( 'Loaded extension: %s %s', extension.dist_name, extension.version) - if entry_point.name != extension.name: + if entry_point.name != extension.ext_name: logger.warning( 'Disabled extension %(ep)s: entry point name (%(ep)s) ' 'does not match extension name (%(ext)s)', - {'ep': entry_point.name, 'ext': extension.name}) + {'ep': entry_point.name, 'ext': extension.ext_name}) continue try: @@ -210,7 +210,7 @@ def load_extensions(): 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)) return extensions @@ -225,7 +225,7 @@ def filter_enabled_extensions(raw_config, extensions): if boolean.deserialize(enabled): 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)) return filtered_extensions diff --git a/mopidy/backends/local/__init__.py b/mopidy/backends/local/__init__.py index a93c8fa8..17fd659e 100644 --- a/mopidy/backends/local/__init__.py +++ b/mopidy/backends/local/__init__.py @@ -6,7 +6,7 @@ from mopidy.utils import config, formatting default_config = """ -[ext.local] +[local] # If the local extension should be enabled or not enabled = true @@ -47,7 +47,7 @@ None class Extension(ext.Extension): dist_name = 'Mopidy-Local' - name = 'local' + ext_name = 'local' version = mopidy.__version__ def get_default_config(self): diff --git a/mopidy/backends/spotify/__init__.py b/mopidy/backends/spotify/__init__.py index a19d7ea8..0e32d4cd 100644 --- a/mopidy/backends/spotify/__init__.py +++ b/mopidy/backends/spotify/__init__.py @@ -7,7 +7,7 @@ from mopidy.utils import config, formatting default_config = """ -[ext.spotify] +[spotify] # If the Spotify extension should be enabled or not enabled = true @@ -68,7 +68,7 @@ https://github.com/mopidy/mopidy/issues?labels=Spotify+backend class Extension(ext.Extension): dist_name = 'Mopidy-Spotify' - name = 'spotify' + ext_name = 'spotify' version = mopidy.__version__ def get_default_config(self): diff --git a/mopidy/backends/stream/__init__.py b/mopidy/backends/stream/__init__.py index 321e4a03..9a393bed 100644 --- a/mopidy/backends/stream/__init__.py +++ b/mopidy/backends/stream/__init__.py @@ -6,7 +6,7 @@ from mopidy.utils import config, formatting default_config = """ -[ext.stream] +[stream] # If the stream extension should be enabled or not enabled = true @@ -46,7 +46,7 @@ None class Extension(ext.Extension): dist_name = 'Mopidy-Stream' - name = 'stream' + ext_name = 'stream' version = mopidy.__version__ def get_default_config(self): diff --git a/mopidy/ext.py b/mopidy/ext.py index 78283617..bc26069c 100644 --- a/mopidy/ext.py +++ b/mopidy/ext.py @@ -6,15 +6,9 @@ from mopidy.utils import config class Extension(object): dist_name = None - name = None + ext_name = 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): raise NotImplementedError( 'Add at least a config section with "enabled = true"') diff --git a/mopidy/frontends/http/__init__.py b/mopidy/frontends/http/__init__.py index d2fe24fc..03bf0a87 100644 --- a/mopidy/frontends/http/__init__.py +++ b/mopidy/frontends/http/__init__.py @@ -6,7 +6,7 @@ from mopidy.utils import config, formatting default_config = """ -[ext.http] +[http] # If the HTTP extension should be enabled or not enabled = true @@ -520,7 +520,7 @@ Example to get started with class Extension(ext.Extension): dist_name = 'Mopidy-HTTP' - name = 'http' + ext_name = 'http' version = mopidy.__version__ def get_default_config(self): diff --git a/mopidy/frontends/lastfm/__init__.py b/mopidy/frontends/lastfm/__init__.py index 7a252170..f4bff0e5 100644 --- a/mopidy/frontends/lastfm/__init__.py +++ b/mopidy/frontends/lastfm/__init__.py @@ -6,7 +6,7 @@ from mopidy.utils import config, formatting default_config = """ -[ext.lastfm] +[lastfm] # If the Last.fm extension should be enabled or not enabled = true @@ -45,7 +45,7 @@ The frontend is enabled by default if all dependencies are available. class Extension(ext.Extension): dist_name = 'Mopidy-Lastfm' - name = 'lastfm' + ext_name = 'lastfm' version = mopidy.__version__ def get_default_config(self): diff --git a/mopidy/frontends/mpd/__init__.py b/mopidy/frontends/mpd/__init__.py index d782c545..08bafd26 100644 --- a/mopidy/frontends/mpd/__init__.py +++ b/mopidy/frontends/mpd/__init__.py @@ -6,7 +6,7 @@ from mopidy.utils import config, formatting default_config = """ -[ext.mpd] +[mpd] # If the MPD extension should be enabled or not enabled = true @@ -89,7 +89,7 @@ near future: class Extension(ext.Extension): dist_name = 'Mopidy-MPD' - name = 'mpd' + ext_name = 'mpd' version = mopidy.__version__ def get_default_config(self): diff --git a/mopidy/frontends/mpris/__init__.py b/mopidy/frontends/mpris/__init__.py index 4b817c73..79806c47 100644 --- a/mopidy/frontends/mpris/__init__.py +++ b/mopidy/frontends/mpris/__init__.py @@ -6,7 +6,7 @@ from mopidy.utils import formatting, config default_config = """ -[ext.mpris] +[mpris] # If the MPRIS extension should be enabled or not enabled = true @@ -71,7 +71,7 @@ Now you can control Mopidy through the player object. Examples: class Extension(ext.Extension): dist_name = 'Mopidy-MPRIS' - name = 'mpris' + ext_name = 'mpris' version = mopidy.__version__ def get_default_config(self): diff --git a/mopidy/utils/config.py b/mopidy/utils/config.py index 00f2b595..d2b34e7d 100644 --- a/mopidy/utils/config.py +++ b/mopidy/utils/config.py @@ -263,8 +263,7 @@ class ConfigSchema(object): class ExtensionConfigSchema(ConfigSchema): """Sub-classed :class:`ConfigSchema` for use in extensions. - Ensures that `enabled` config value is present and that section name is - prefixed with ext. + Ensures that `enabled` config value is present. """ def __init__(self): super(ExtensionConfigSchema, self).__init__() diff --git a/tests/ext_test.py b/tests/ext_test.py index b967f951..b58333c2 100644 --- a/tests/ext_test.py +++ b/tests/ext_test.py @@ -13,16 +13,9 @@ class ExtensionTest(unittest.TestCase): def test_dist_name_is_none(self): self.assertIsNone(self.ext.dist_name) - def test_name_is_none(self): - self.assertIsNone(self.ext.name) - def test_ext_name_is_none(self): 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): self.assertIsNone(self.ext.version)