diff options
author | jaseg <s@jaseg.de> | 2013-04-02 17:05:12 +0200 |
---|---|---|
committer | jaseg <s@jaseg.de> | 2013-04-02 17:05:12 +0200 |
commit | cccea7324cd692e7926595d9c1a248602c027067 (patch) | |
tree | 75fcf4d0615255d37ef072bd7d0ce8dc51ee847f | |
parent | 98c4945d57d274ae0e5b88c0eaab2371faaf1415 (diff) | |
download | ponysay-cccea7324cd692e7926595d9c1a248602c027067.tar.gz ponysay-cccea7324cd692e7926595d9c1a248602c027067.tar.bz2 ponysay-cccea7324cd692e7926595d9c1a248602c027067.zip |
Small style fixes
-rwxr-xr-x | ponysay.py | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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' |