From 5d6f3db6a0a6e65a9eb81cede4c59c7d22f2cae0 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 20 Jun 2020 22:33:11 +0200 Subject: op-mode: T2621: fix repeated interface description --- src/op_mode/show_interfaces.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/op_mode/show_interfaces.py b/src/op_mode/show_interfaces.py index ebb3508f0..46571c0c0 100755 --- a/src/op_mode/show_interfaces.py +++ b/src/op_mode/show_interfaces.py @@ -96,10 +96,14 @@ def split_text(text, used=0): line = '' for word in text.split(): - if len(line) + len(word) >= desc_len: - yield f'{line} {word}'[1:] - line = '' - line = f'{line} {word}' + if len(line) + len(word) < desc_len: + line = f'{line} {word}' + continue + if line: + yield line[1:] + else: + line = f'{line} {word}' + yield line[1:] -- cgit v1.2.3