Merge "Format resource required_by in resource-show."
This commit is contained in:
commit
9cba3dab02
@ -47,6 +47,10 @@ def text_wrap_formatter(d):
|
||||
return '\n'.join(textwrap.wrap(d or '', 55))
|
||||
|
||||
|
||||
def newline_list_formatter(r):
|
||||
return '\n'.join(r or [])
|
||||
|
||||
|
||||
def print_list(objs, fields, field_labels=None, formatters={}, sortby=0):
|
||||
field_labels = field_labels or fields
|
||||
pt = prettytable.PrettyTable([f for f in field_labels],
|
||||
|
@ -80,3 +80,9 @@ class shellTest(testtools.TestCase):
|
||||
utils.text_wrap_formatter(
|
||||
('one two three four five six seven '
|
||||
'eight nine ten eleven twelve')))
|
||||
|
||||
def test_newline_list_formatter(self):
|
||||
self.assertEqual('', utils.newline_list_formatter(None))
|
||||
self.assertEqual('', utils.newline_list_formatter([]))
|
||||
self.assertEqual('one\ntwo',
|
||||
utils.newline_list_formatter(['one', 'two']))
|
||||
|
@ -364,6 +364,7 @@ def do_resource_show(hc, args):
|
||||
else:
|
||||
formatters = {
|
||||
'links': utils.link_formatter,
|
||||
'required_by': utils.newline_list_formatter
|
||||
}
|
||||
utils.print_dict(resource.to_dict(), formatters=formatters)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user