diff options
author | Bjoern Tropf <asymmail@googlemail.com> | 2009-08-22 14:09:42 +0200 |
---|---|---|
committer | Bjoern Tropf <asymmail@googlemail.com> | 2009-08-22 14:09:42 +0200 |
commit | 7088a6069ed502846f7d4be6e1270021ab3a47e0 (patch) | |
tree | ff87a01ea42da5501e1bd225785b24ed4e7b7ba5 | |
parent | Further work on output (diff) | |
download | kernel-check-7088a6069ed502846f7d4be6e1270021ab3a47e0.tar.gz kernel-check-7088a6069ed502846f7d4be6e1270021ab3a47e0.tar.bz2 kernel-check-7088a6069ed502846f7d4be6e1270021ab3a47e0.zip |
Use textwrap.wrap() instead of own implementation
-rwxr-xr-x | kernel-check.py | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/kernel-check.py b/kernel-check.py index b486998..72959cf 100755 --- a/kernel-check.py +++ b/kernel-check.py @@ -6,6 +6,7 @@ import getopt import portage import sys +import textwrap import os import kernellib as lib @@ -190,38 +191,27 @@ def print_bug(bugid): print '' print_cve(cve) + def print_cve(cve): 'Prints information about a cve' info('Cve : ' + cve.cve + ' - ' + cve.published) info('Severity : ' + cve.severity + ' ' + cve.score + ' - ' + cve.vector) - info('Desc : ' + break_line('"' + cve.desc + '"', 14)[14:]) #TODO print cve.refs + + for i, string in enumerate(textwrap.wrap('"%s"' % cve.desc , + (term[1] - 13))): + if i is 0: + info('Desc : ' + string) + else: + print ' ' * 15 + string return -def break_line(string, indent): - 'Breaks the line at the last whitespace' - - ret = str() - last_space = 0 - p_last_space = 0; - - for i, char in enumerate(string): - if char == ' ': - last_space = i; - - if i % (term[1] - indent) is 0 and i is not 0: - ret += (' ' * indent) + string[p_last_space:last_space] + '\n' - p_last_space = last_space - - if i == len(string) - 1: #FIXME why does 'is' not work? - ret += (' ' * indent) + string[p_last_space:len(string)] - - return ret - def print_beta(): + 'Prints a beta warning message' + print '' error('%s You are using a very early version of kernel-check!' % color('BAD', 'IMPORTANT')) |