diff options
author | imarom <imarom@cisco.com> | 2017-01-18 13:08:41 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2017-01-18 13:08:41 +0200 |
commit | 951b09ef1b892594840f091f861f11ad274541ec (patch) | |
tree | 1fe935fb6cdbf22308971b081e7685fdb1f185bb /scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py | |
parent | 9f72a19a6bb0edf7ad54129f7ad06e8e288a61d7 (diff) |
many capture modes in Python console
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py')
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py | 16 |
1 files changed, 10 insertions, 6 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 63b05bf4..3ffd07e2 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 @@ -133,12 +133,16 @@ def underline(text): # apply attribute on each non-empty line def text_attribute(text, attribute): - 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')]) - + if isinstance(text, str): + return "{start}{txt}{stop}".format(start=TEXT_CODES[attribute]['start'], + txt=text, + stop=TEXT_CODES[attribute]['end']) + elif isinstance(text, unicode): + return u"{start}{txt}{stop}".format(start=TEXT_CODES[attribute]['start'], + txt=text, + stop=TEXT_CODES[attribute]['end']) + else: + raise Exception("not a string") FUNC_DICT = {'blue': blue, 'bold': bold, |