Merge branch 'release/v0.19.x' into develop
This commit is contained in:
commit
6ec35b2d02
@ -75,6 +75,12 @@ v0.19.5 (UNRELEASED)
|
|||||||
|
|
||||||
Bug fix release.
|
Bug fix release.
|
||||||
|
|
||||||
|
- config: Support UTF-8 in default config. If an extension with non-ASCII
|
||||||
|
characters in its default config was installed, and Mopidy didn't already
|
||||||
|
have a config file, Mopidy would crashed when trying to create the initial
|
||||||
|
config file based on the default config of all available extensions.
|
||||||
|
(Fixes: :discuss:`428`)
|
||||||
|
|
||||||
- Models: Hide empty collections from :func:`repr()` representations.
|
- Models: Hide empty collections from :func:`repr()` representations.
|
||||||
|
|
||||||
- Models: Field values are no longer stored on the model instance when the
|
- Models: Field values are no longer stored on the model instance when the
|
||||||
|
|||||||
@ -157,6 +157,7 @@ extlinks = {
|
|||||||
'commit': ('https://github.com/mopidy/mopidy/commit/%s', 'commit '),
|
'commit': ('https://github.com/mopidy/mopidy/commit/%s', 'commit '),
|
||||||
'mpris': (
|
'mpris': (
|
||||||
'https://github.com/mopidy/mopidy-mpris/issues/%s', 'mopidy-mpris#'),
|
'https://github.com/mopidy/mopidy-mpris/issues/%s', 'mopidy-mpris#'),
|
||||||
|
'discuss': ('https://discuss.mopidy.com/t/%s', 'discuss.mopidy.com/t/'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -98,8 +98,12 @@ def format_initial(extensions):
|
|||||||
versions = ['Mopidy %s' % versioning.get_version()]
|
versions = ['Mopidy %s' % versioning.get_version()]
|
||||||
for extension in sorted(extensions, key=lambda ext: ext.dist_name):
|
for extension in sorted(extensions, key=lambda ext: ext.dist_name):
|
||||||
versions.append('%s %s' % (extension.dist_name, extension.version))
|
versions.append('%s %s' % (extension.dist_name, extension.version))
|
||||||
description = _INITIAL_HELP.strip() % {'versions': '\n# '.join(versions)}
|
|
||||||
return description + '\n\n' + _format(config, {}, schemas, False, True)
|
header = _INITIAL_HELP.strip() % {'versions': '\n# '.join(versions)}
|
||||||
|
formatted_config = _format(
|
||||||
|
config=config, comments={}, schemas=schemas,
|
||||||
|
display=False, disable=True).decode('utf-8')
|
||||||
|
return header + '\n\n' + formatted_config
|
||||||
|
|
||||||
|
|
||||||
def _load(files, defaults, overrides):
|
def _load(files, defaults, overrides):
|
||||||
|
|||||||
@ -46,12 +46,14 @@ def get_or_create_file(file_path, mkdir=True, content=None):
|
|||||||
if not isinstance(file_path, bytes):
|
if not isinstance(file_path, bytes):
|
||||||
raise ValueError('Path is not a bytestring.')
|
raise ValueError('Path is not a bytestring.')
|
||||||
file_path = expand_path(file_path)
|
file_path = expand_path(file_path)
|
||||||
|
if isinstance(content, compat.text_type):
|
||||||
|
content = content.encode('utf-8')
|
||||||
if mkdir:
|
if mkdir:
|
||||||
get_or_create_dir(os.path.dirname(file_path))
|
get_or_create_dir(os.path.dirname(file_path))
|
||||||
if not os.path.isfile(file_path):
|
if not os.path.isfile(file_path):
|
||||||
logger.info('Creating file %s', file_path)
|
logger.info('Creating file %s', file_path)
|
||||||
with open(file_path, 'w') as fh:
|
with open(file_path, 'wb') as fh:
|
||||||
if content:
|
if content is not None:
|
||||||
fh.write(content)
|
fh.write(content)
|
||||||
return file_path
|
return file_path
|
||||||
|
|
||||||
|
|||||||
@ -107,12 +107,12 @@ class GetOrCreateFileTest(unittest.TestCase):
|
|||||||
with self.assertRaises(IOError):
|
with self.assertRaises(IOError):
|
||||||
path.get_or_create_file(conflicting_dir)
|
path.get_or_create_file(conflicting_dir)
|
||||||
|
|
||||||
def test_create_dir_with_unicode(self):
|
def test_create_dir_with_unicode_filename_throws_value_error(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
file_path = compat.text_type(os.path.join(self.parent, b'test'))
|
file_path = compat.text_type(os.path.join(self.parent, b'test'))
|
||||||
path.get_or_create_file(file_path)
|
path.get_or_create_file(file_path)
|
||||||
|
|
||||||
def test_create_file_with_none(self):
|
def test_create_file_with_none_filename_throws_value_error(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
path.get_or_create_file(None)
|
path.get_or_create_file(None)
|
||||||
|
|
||||||
@ -121,12 +121,18 @@ class GetOrCreateFileTest(unittest.TestCase):
|
|||||||
with self.assertRaises(IOError):
|
with self.assertRaises(IOError):
|
||||||
path.get_or_create_file(file_path, mkdir=False)
|
path.get_or_create_file(file_path, mkdir=False)
|
||||||
|
|
||||||
def test_create_dir_with_default_content(self):
|
def test_create_dir_with_bytes_content(self):
|
||||||
file_path = os.path.join(self.parent, b'test')
|
file_path = os.path.join(self.parent, b'test')
|
||||||
created = path.get_or_create_file(file_path, content=b'foobar')
|
created = path.get_or_create_file(file_path, content=b'foobar')
|
||||||
with open(created) as fh:
|
with open(created) as fh:
|
||||||
self.assertEqual(fh.read(), b'foobar')
|
self.assertEqual(fh.read(), b'foobar')
|
||||||
|
|
||||||
|
def test_create_dir_with_unicode_content(self):
|
||||||
|
file_path = os.path.join(self.parent, b'test')
|
||||||
|
created = path.get_or_create_file(file_path, content='foobaræøå')
|
||||||
|
with open(created) as fh:
|
||||||
|
self.assertEqual(fh.read(), b'foobaræøå')
|
||||||
|
|
||||||
|
|
||||||
class PathToFileURITest(unittest.TestCase):
|
class PathToFileURITest(unittest.TestCase):
|
||||||
def test_simple_path(self):
|
def test_simple_path(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user