deps: Output one dep per line
This commit is contained in:
parent
21d17db7e2
commit
5de80228ea
@ -39,19 +39,31 @@ def format_dependency_list(adapters=None):
|
||||
ws4py_info,
|
||||
]
|
||||
|
||||
return '\n'.join([_format_dependency(a()) for a in adapters])
|
||||
|
||||
|
||||
def _format_dependency(dep_info):
|
||||
lines = []
|
||||
for adapter in adapters:
|
||||
dep_info = adapter()
|
||||
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: %s' % (
|
||||
os.path.dirname(dep_info['path'])))
|
||||
if 'other' in dep_info:
|
||||
lines.append(' Other: %s' % (
|
||||
formatting.indent(dep_info['other'])),)
|
||||
|
||||
if 'version' not in dep_info:
|
||||
lines.append('%s: not found' % dep_info['name'])
|
||||
else:
|
||||
lines.append('%s: %s from %s' % (
|
||||
dep_info['name'],
|
||||
dep_info['version'],
|
||||
os.path.dirname(dep_info.get('path', 'none')),
|
||||
))
|
||||
|
||||
if 'other' in dep_info:
|
||||
lines.append(' Detailed information: %s' % (
|
||||
formatting.indent(dep_info['other'], places=4)),)
|
||||
|
||||
if dep_info.get('dependencies', []):
|
||||
for sub_dep_info in dep_info['dependencies']:
|
||||
sub_dep_lines = _format_dependency(sub_dep_info)
|
||||
lines.append(
|
||||
formatting.indent(sub_dep_lines, places=2, singles=True))
|
||||
|
||||
return '\n'.join(lines)
|
||||
|
||||
|
||||
|
||||
@ -47,17 +47,32 @@ 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', path='/foo/bar/baz.py', other='Quux')
|
||||
lambda: dict(
|
||||
name='Pykka', version='1.1',
|
||||
path='/foo/bar/baz.py', other='Quux'),
|
||||
lambda: dict(name='Foo'),
|
||||
lambda: dict(name='Mopidy', version='0.13', dependencies=[
|
||||
dict(name='pylast', version='0.5', dependencies=[
|
||||
dict(name='setuptools', version='0.6')
|
||||
])
|
||||
])
|
||||
]
|
||||
|
||||
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', result)
|
||||
|
||||
self.assertIn('Pykka: 1.1 from /foo/bar', result)
|
||||
self.assertNotIn('/baz.py', result)
|
||||
self.assertIn('Quux', result)
|
||||
self.assertIn('Detailed information: Quux', result)
|
||||
|
||||
self.assertIn('Foo: not found', result)
|
||||
|
||||
self.assertIn('Mopidy: 0.13', result)
|
||||
self.assertIn(' pylast: 0.5', result)
|
||||
self.assertIn(' setuptools: 0.6', result)
|
||||
|
||||
def test_platform_info(self):
|
||||
result = deps.platform_info()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user