From f3004ed4d27d5c13f79d762f7c8b48fa719b4925 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 1 Apr 2013 22:05:10 +0200 Subject: [PATCH 1/2] config: Fix flake8 warnings --- mopidy/utils/config.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/mopidy/utils/config.py b/mopidy/utils/config.py index fad641f1..b26c4f0a 100644 --- a/mopidy/utils/config.py +++ b/mopidy/utils/config.py @@ -9,7 +9,7 @@ from mopidy import exceptions def validate_choice(value, choices): """Choice validation, normally called in config value's validate().""" - if choices is not None and value not in choices : + if choices is not None and value not in choices: names = ', '.join(repr(c) for c in choices) raise ValueError('must be one of %s, not %s.' % (names, value)) @@ -131,15 +131,18 @@ class List(ConfigValue): class LogLevel(ConfigValue): - levels = {'critical' : logging.CRITICAL, - 'error' : logging.ERROR, - 'warning' : logging.WARNING, - 'info' : logging.INFO, - 'debug' : logging.DEBUG} + levels = { + 'critical': logging.CRITICAL, + 'error': logging.ERROR, + 'warning': logging.WARNING, + 'info': logging.INFO, + 'debug': logging.DEBUG, + } def deserialize(self, value): if value.lower() not in self.levels: - raise ValueError('%r must be one of %s.' % (value, ', '.join(self.levels))) + raise ValueError('%r must be one of %s.' % ( + value, ', '.join(self.levels))) return self.levels.get(value.lower()) def serialize(self, value): @@ -159,16 +162,16 @@ class Port(Integer): def __init__(self, **kwargs): super(Port, self).__init__(**kwargs) self.minimum = 1 - self.maximum = 2**16 - 1 + self.maximum = 2 ** 16 - 1 class ConfigSchema(object): """Logical group of config values that correspond to a config section. - Schemas are set up by assigning config keys with config values to instances. - Once setup :meth:`convert` can be called with a list of `(key, value)` tuples to - process. For convienience we also support :meth:`format` method that can used - for printing out the converted values. + Schemas are set up by assigning config keys with config values to + instances. Once setup :meth:`convert` can be called with a list of `(key, + value)` tuples to process. For convienience we also support :meth:`format` + method that can used for printing out the converted values. """ # TODO: Use collections.OrderedDict once 2.6 support is gone (#344) def __init__(self): @@ -188,7 +191,8 @@ class ConfigSchema(object): for key in self._order: value = values.get(key) if value is not None: - lines.append('%s = %s' % (key, self._schema[key].format(value))) + lines.append('%s = %s' % ( + key, self._schema[key].format(value))) return '\n'.join(lines) def convert(self, items): @@ -226,7 +230,8 @@ class ExtensionConfigSchema(ConfigSchema): self['enabled'] = Boolean() def format(self, name, values): - return super(ExtensionConfigSchema, self).format('ext.%s' % name, values) + return super(ExtensionConfigSchema, self).format( + 'ext.%s' % name, values) class LogLevelConfigSchema(object): @@ -243,7 +248,8 @@ class LogLevelConfigSchema(object): lines = ['[%s]' % name] for key, value in sorted(values.items()): if value is not None: - lines.append('%s = %s' % (key, self._config_value.format(value))) + lines.append('%s = %s' % ( + key, self._config_value.format(value))) return '\n'.join(lines) def convert(self, items): From 4a8b7c763e377cca5ad908f19d70c99b1b13ee74 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 1 Apr 2013 22:10:18 +0200 Subject: [PATCH 2/2] docs: Remove py_modules comment from example setup.py --- docs/extensiondev.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/extensiondev.rst b/docs/extensiondev.rst index 7b4bc374..43b0b723 100644 --- a/docs/extensiondev.rst +++ b/docs/extensiondev.rst @@ -159,9 +159,6 @@ class that will connect the rest of the dots. description='Very short description', long_description=open('README.rst').read(), packages=['mopidy_soundspot'], - # If you ship package instead of a single module instead, use - # 'py_modules' instead of 'packages': - #py_modules=['mopidy_soundspot'], zip_safe=False, include_package_data=True, install_requires=[