diff options
| author | Dylan Araps <[email protected]> | 2017-06-20 20:19:24 +1000 |
|---|---|---|
| committer | Dylan Araps <[email protected]> | 2017-06-20 20:19:24 +1000 |
| commit | 5d02958326b808bcf73ae3941525bcb7e491235c (patch) | |
| tree | 309cca2397747f1701f2bf6526a8604c08be53cc /wal | |
| parent | Optimization: Remove glob import (diff) | |
| download | pywal-5d02958326b808bcf73ae3941525bcb7e491235c.tar.xz pywal-5d02958326b808bcf73ae3941525bcb7e491235c.zip | |
Optimization: Use faster for loops
Diffstat (limited to 'wal')
| -rwxr-xr-x | wal | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -21,7 +21,8 @@ COLOR_COUNT = 16 CACHE_DIR = pathlib.Path.home() / ".cache/wal/" -class ColorFormats(object): # pylint: disable=too-few-public-methods +# pylint: disable=too-few-public-methods +class ColorFormats(object): """Store colors in various formats.""" x_colors = [] sequences = [] @@ -276,8 +277,8 @@ def send_sequences(colors, vte): set_special(708, colors[0]) # Create the sequences. - for num, color in enumerate(colors): - set_color(num, color) + # pylint: disable=W0106 + [set_color(num, color) for num, color in enumerate(colors)] # Set a blank color that isn"t affected by bold highlighting. set_color(66, colors[0]) @@ -286,14 +287,14 @@ def send_sequences(colors, vte): sequences = "".join(ColorFormats.sequences) sequences = bytes(sequences, "utf-8").decode("unicode_escape") - # Send the sequences to all open terminals. + # Get a list of terminals. terminals = ["%s%s" % ("/dev/pts/", term) for term in os.listdir("/dev/pts/") if len(term) < 4] terminals.append(CACHE_DIR / "sequences") - for term in terminals: - with open(term, "w") as file: - file.write(sequences) + # Send the sequences to all open terminals. + # pylint: disable=W0106 + [save_file(sequences, term) for term in terminals] print("colors: Set terminal colors") |