summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/utils')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py
index 6c5dd2c3..63b05bf4 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py
@@ -131,21 +131,13 @@ def yellow(text):
def underline(text):
return text_attribute(text, 'underline')
-
-start_end_newlines = re.compile('^(\n)*([^\n].*[^\n])?(\n)*$', re.DOTALL)
+# apply attribute on each non-empty line
def text_attribute(text, attribute):
- match = start_end_newlines.match(text)
- try:
- startpad, msg, endpad = match.groups('')
- except:
- startpad = endpad = ''
- msg = text
- return "{startpad}{startattr}{txt}{endattr}{endpad}".format(
- startpad = startpad,
- startattr = TEXT_CODES[attribute]['start'],
- txt = msg,
- endattr = TEXT_CODES[attribute]['end'],
- endpad = endpad)
+ return '\n'.join(['{start}{txt}{end}'.format(
+ start = TEXT_CODES[attribute]['start'],
+ txt = line,
+ end = TEXT_CODES[attribute]['end'])
+ if line else '' for line in ('%s' % text).split('\n')])
FUNC_DICT = {'blue': blue,