From cccea7324cd692e7926595d9c1a248602c027067 Mon Sep 17 00:00:00 2001 From: jaseg Date: Tue, 2 Apr 2013 17:05:12 +0200 Subject: Small style fixes --- ponysay.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ponysay.py b/ponysay.py index 1ec0cc5..23239a5 100755 --- a/ponysay.py +++ b/ponysay.py @@ -51,13 +51,12 @@ def render_balloon(text, balloonstyle, minwidth=0, maxwidth=40, pad=str.center): (oneline, multiline, bottom, top, linkl, linkr) = balloonstyle lines = [ ' '+wrapline+' ' for textline in text.center(minwidth).split('\n') for wrapline in textwrap.wrap(textline, maxwidth) ] width = max([ len(line) for line in lines ]+[minwidth]) - def side(top, middle, bottom): - return top + middle*(len(lines)-2) + bottom + side = lambda top, middle, bottom: top + middle*(len(lines)-2) + bottom leftside, rightside = oneline if len(lines) == 1 else multiline topextra, bottomextra = len(leftside[0])-2, len(leftside[2])-2 leftside, rightside = side(*leftside), side(*rightside) lines = [top*width] + [' '*width]*topextra + [ pad(line, width) for line in lines ] + [' '*width]*bottomextra + [bottom*width] - return [ l+m+r for l,m,r in zip(leftside, lines, rightside)] + return [ l+m+r for l,m,r in zip(leftside, lines, rightside) ] def render_pony(name, text, balloonstyle, width=80, center=False, centertext=False): pony = load_pony(name) #CAUTION: these lines already end with '\n' -- cgit