[PR] #303 from luna-1024: Fix custom_colors keys type mismatch

Fix ColorAlignment.custom_colors.keys() / slots type mismatch
This commit is contained in:
2024-10-23 08:59:45 -07:00
committed by GitHub
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -248,7 +248,7 @@ def create_config() -> Config:
# Random color schemes
pis = list(range(len(_prs.unique_colors().colors)))
slots = list(set(re.findall('(?<=\\${c)[0-9](?=})', asc)))
slots = list(set(map(int, re.findall('(?<=\\${c)[0-9](?=})', asc))))
while len(pis) < len(slots):
pis += pis
perm = {p[:len(slots)] for p in permutations(pis)}
+4 -1
View File
@@ -129,7 +129,10 @@ class ColorAlignment:
@classmethod
def from_dict(cls, d: dict):
return from_dict(cls, d)
ca = from_dict(cls, d)
# Fixup: Keys must json serialize as str, so we convert them back to int.
ca.custom_colors = {int(k): v for k, v in ca.custom_colors.items()}
return ca
def recolor_ascii(self, asc: str, preset: ColorProfile) -> str:
"""