Fix ColorAlignment.custom_colors.keys() / slots type mismatch

This commit is contained in:
Luna 2024-05-29 17:50:46 -07:00
parent 2a01c50aa6
commit 45347e0714
2 changed files with 5 additions and 2 deletions

View file

@ -247,7 +247,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)}

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:
"""