Code review: succint and pythonic statements
This commit is contained in:
parent
f855c9078f
commit
e72f0c832d
1 changed files with 3 additions and 12 deletions
|
|
@ -161,21 +161,12 @@ def _to_rect(lines):
|
||||||
lines (list): list of `ANSIString`s
|
lines (list): list of `ANSIString`s
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
nlines (list): list of `ANSIString`s of
|
(list): list of `ANSIString`s of
|
||||||
same length as the longest input line
|
same length as the longest input line
|
||||||
|
|
||||||
"""
|
"""
|
||||||
maxl = 0
|
maxl = max(len(line) for line in lines)
|
||||||
for line in lines:
|
return [line + ' ' * (maxl - len(line)) for line in lines]
|
||||||
if isinstance(line, (ANSIString, basestring)):
|
|
||||||
maxl = max(len(line), maxl)
|
|
||||||
else:
|
|
||||||
raise ValueError()
|
|
||||||
nlines = []
|
|
||||||
for line in lines:
|
|
||||||
line += ' ' * (maxl - len(line))
|
|
||||||
nlines.append(line)
|
|
||||||
return nlines
|
|
||||||
|
|
||||||
|
|
||||||
def _to_ansi(obj, regexable=False):
|
def _to_ansi(obj, regexable=False):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue