colors: Add error handling to reload

This commit is contained in:
Dylan Araps 2017-06-21 22:32:34 +10:00
parent b684e1604e
commit 0a64877b1e

19
wal
View File

@ -498,17 +498,20 @@ def read_file(input_file):
def reload_colors(vte): def reload_colors(vte):
"""Reload colors.""" """Reload colors."""
with open(CACHE_DIR / "sequences") as file: sequence_file = pathlib.Path(CACHE_DIR / "sequences")
sequences = file.read()
# If vte mode was used, remove the problem sequence. if sequence_file.is_file():
if vte: with open(sequence_file, "r") as file:
sequences = re.sub(r"\]708;\#.{6}", "", sequences) sequences = file.read()
# Decode the string. # If vte mode was used, remove the problem sequence.
sequences = bytes(sequences, "utf-8").decode("unicode_escape") if vte:
sequences = re.sub(r"\]708;\#.{6}", "", sequences)
# Decode the string.
sequences = bytes(sequences, "utf-8").decode("unicode_escape")
print(sequences, end="")
print(sequences, end="")
quit() quit()