diff options
author | jaseg <s@jaseg.de> | 2013-08-17 20:10:20 +0200 |
---|---|---|
committer | jaseg <s@jaseg.de> | 2013-08-17 20:10:20 +0200 |
commit | ea24fc5026cc85ba363c9a6496789a018498ece4 (patch) | |
tree | 6d1e33dfa5cbd92a98c55fffe45246c124fbc48e | |
parent | bcf2ffdb8faa08b7486a29157241bf40b77de2a6 (diff) | |
download | ponysay-ea24fc5026cc85ba363c9a6496789a018498ece4.tar.gz ponysay-ea24fc5026cc85ba363c9a6496789a018498ece4.tar.bz2 ponysay-ea24fc5026cc85ba363c9a6496789a018498ece4.zip |
Small performance & clarity improvement
-rw-r--r-- | ponysay.py | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -73,5 +73,6 @@ def render_pony(name, text, balloonstyle, width=80, center=False, centertext=Fal ponywidth = max([ len(re.sub(r'\x1B\[[0-9;]+m|\$.*\$', '', line)) for line in pony ]) indent = ' '*int((width-ponywidth)/2) wre = re.compile('((\x1B\[[0-9;]+m)*.){0,%s}' % width) - return ''.join([ indent+wre.search(line).group()+'[49m\n' for line in pony ]) + reset = '[39;49m\n' + return indent+(reset+indent).join([ wre.search(line).group() for line in pony ])+reset |