mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
output: refactor terse formatting into a single function
This commit is contained in:
parent
4e93830df9
commit
c09323d276
@ -77,25 +77,13 @@ def output(data):
|
||||
if __opts__.get('state_output', 'full').lower() == 'terse':
|
||||
# Print this chunk in a terse way and continue in the
|
||||
# loop
|
||||
msg = (' {0}Name: {1} - Function: {2}.{3} - '
|
||||
'Result: {4}{5}').format(tcolor,
|
||||
comps[2],
|
||||
comps[0],
|
||||
comps[-1],
|
||||
str(ret['result']),
|
||||
colors['ENDC'])
|
||||
msg = _format_terse(tcolor, comps, ret, colors)
|
||||
hstrs.append(msg)
|
||||
continue
|
||||
elif __opts__.get('state_output', 'full').lower() == 'mixed':
|
||||
# Print terse unless it failed
|
||||
if ret['result'] is not False:
|
||||
msg = (' {0}Name: {1} - Function: {2}.{3} - '
|
||||
'Result: {4}{5}').format(tcolor,
|
||||
comps[2],
|
||||
comps[0],
|
||||
comps[-1],
|
||||
str(ret['result']),
|
||||
colors['ENDC'])
|
||||
msg = _format_terse(tcolor, comps, ret, colors)
|
||||
hstrs.append(msg)
|
||||
continue
|
||||
hstrs.append(('{0}----------\n State: - {1}{2[ENDC]}'
|
||||
@ -159,3 +147,18 @@ def _strip_clean(returns):
|
||||
for tag in rm_tags:
|
||||
returns.pop(tag)
|
||||
return returns
|
||||
|
||||
|
||||
def _format_terse(tcolor, comps, ret, colors):
|
||||
'''
|
||||
Terse formatting of a message.
|
||||
'''
|
||||
msg = (' {0}Name: {1} - Function: {2}.{3} - '
|
||||
'Result: {4}{5}').format(tcolor,
|
||||
comps[2],
|
||||
comps[0],
|
||||
comps[-1],
|
||||
str(ret['result']),
|
||||
colors['ENDC'])
|
||||
|
||||
return msg
|
||||
|
Loading…
Reference in New Issue
Block a user