Add pyspotify adapter for --list-deps
This commit is contained in:
parent
5fcc4e67aa
commit
a25e7d9530
@ -2,6 +2,8 @@ import sys
|
||||
|
||||
import pykka
|
||||
|
||||
from mopidy.utils.log import indent
|
||||
|
||||
|
||||
def list_deps_optparse_callback(*args):
|
||||
"""
|
||||
@ -18,14 +20,21 @@ def format_dependency_list(adapters=None):
|
||||
if adapters is None:
|
||||
adapters = [
|
||||
pykka_info,
|
||||
pyspotify_info,
|
||||
]
|
||||
|
||||
lines = []
|
||||
for adapter in adapters:
|
||||
dep_info = adapter()
|
||||
lines.append('%(name)s: %(version)s' % dep_info)
|
||||
lines.append('%(name)s: %(version)s' % {
|
||||
'name': dep_info['name'],
|
||||
'version': dep_info.get('version', 'not found'),
|
||||
})
|
||||
if 'path' in dep_info:
|
||||
lines.append(' Imported from: %(path)s' % dep_info)
|
||||
if 'other' in dep_info:
|
||||
lines.append(' Other: %s' % (
|
||||
indent(dep_info['other'])),)
|
||||
return '\n'.join(lines)
|
||||
|
||||
|
||||
@ -41,3 +50,19 @@ def pykka_info():
|
||||
'version': version,
|
||||
'path': pykka.__file__,
|
||||
}
|
||||
|
||||
|
||||
def pyspotify_info():
|
||||
dep_info = {'name': 'pyspotify'}
|
||||
try:
|
||||
import spotify
|
||||
if hasattr(spotify, '__version__'):
|
||||
dep_info['version'] = spotify.__version__
|
||||
else:
|
||||
dep_info['version'] = '< 1.3'
|
||||
dep_info['path'] = spotify.__file__
|
||||
dep_info['other'] = 'Built for libspotify API version %d' % (
|
||||
spotify.api_version,)
|
||||
except ImportError:
|
||||
pass
|
||||
return dep_info
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import pykka
|
||||
import spotify
|
||||
|
||||
from mopidy.utils import deps
|
||||
|
||||
@ -10,14 +11,16 @@ class DepsTest(unittest.TestCase):
|
||||
adapters = [
|
||||
lambda: dict(name='Python', version='FooPython 2.7.3'),
|
||||
lambda: dict(name='Platform', version='Loonix 4.0.1'),
|
||||
lambda: dict(name='Pykka', version='0.1337', path='/foo/bar/baz')
|
||||
lambda: dict(name='Pykka', path='/foo/bar/baz', other='Quux')
|
||||
]
|
||||
|
||||
result = deps.format_dependency_list(adapters)
|
||||
|
||||
self.assertIn('Python: FooPython 2.7.3', result)
|
||||
self.assertIn('Platform: Loonix 4.0.1', result)
|
||||
self.assertIn('Pykka: not found', result)
|
||||
self.assertIn('Imported from: /foo/bar/baz', result)
|
||||
self.assertIn('Quux', result)
|
||||
|
||||
def test_pykka_info(self):
|
||||
result = deps.pykka_info()
|
||||
@ -25,3 +28,12 @@ class DepsTest(unittest.TestCase):
|
||||
self.assertEquals('Pykka', result['name'])
|
||||
self.assertEquals(pykka.__version__, result['version'])
|
||||
self.assertIn('pykka', result['path'])
|
||||
|
||||
def test_pyspotify_info(self):
|
||||
result = deps.pyspotify_info()
|
||||
|
||||
self.assertEquals('pyspotify', result['name'])
|
||||
self.assertEquals(spotify.__version__, result['version'])
|
||||
self.assertIn('spotify', result['path'])
|
||||
self.assertIn('Built for libspotify API version', result['other'])
|
||||
self.assertIn(str(spotify.api_version), result['other'])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user