diff options
author | mathieui <mathieui@mathieui.net> | 2017-11-12 15:03:09 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2017-11-12 15:03:09 +0100 |
commit | d55cc5872503567775f0d7a7731d6f489bf2299b (patch) | |
tree | 725f9e7b8144d36054447b3c82edfb45bda8df1d /poezio/windows/funcs.py | |
parent | 92496db823db34f7f7fb1ab31eaef093a707c3e8 (diff) | |
download | poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.gz poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.bz2 poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.xz poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.zip |
yapf -ir
Diffstat (limited to 'poezio/windows/funcs.py')
-rw-r--r-- | poezio/windows/funcs.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/poezio/windows/funcs.py b/poezio/windows/funcs.py index ea2941c8..3648bac3 100644 --- a/poezio/windows/funcs.py +++ b/poezio/windows/funcs.py @@ -7,6 +7,7 @@ DIGITS = string.digits + '-' from poezio.windows.base_wins import FORMAT_CHAR, format_chars + def find_first_format_char(text, chars=None): if chars is None: chars = format_chars @@ -19,13 +20,15 @@ def find_first_format_char(text, chars=None): pos = p return pos + def truncate_nick(nick, size=10): if size < 1: size = 1 if nick and len(nick) > size: - return nick[:size]+'…' + return nick[:size] + '…' return nick + def parse_attrs(text, previous=None): next_attr_char = text.find(FORMAT_CHAR) if previous: @@ -34,7 +37,7 @@ def parse_attrs(text, previous=None): attrs = [] while next_attr_char != -1 and text: if next_attr_char + 1 < len(text): - attr_char = text[next_attr_char+1].lower() + attr_char = text[next_attr_char + 1].lower() else: attr_char = '\0' if attr_char == 'o': @@ -46,12 +49,11 @@ def parse_attrs(text, previous=None): elif attr_char == 'i': attrs.append('i') if attr_char in DIGITS and attr_char: - color_str = text[next_attr_char+1:text.find('}', next_attr_char)] + color_str = text[next_attr_char + 1:text.find('}', next_attr_char)] if color_str: attrs.append(color_str + '}') - text = text[next_attr_char+len(color_str)+2:] + text = text[next_attr_char + len(color_str) + 2:] else: - text = text[next_attr_char+2:] + text = text[next_attr_char + 2:] next_attr_char = text.find(FORMAT_CHAR) return attrs - |