Skip to content

Commit

Permalink
fix config special chars
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenZcience committed Feb 29, 2024
1 parent 990324d commit bf4e196
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cat_win/persistence/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def convert_config_element(element: str, element_type: type):
return False
return True

return element_type(element)
return element_type(element.encode().decode('unicode_escape'))

@staticmethod
def is_valid_value(value: str, value_type: type) -> bool:
Expand Down Expand Up @@ -181,14 +181,13 @@ def save_config(self) -> None:
value = None
while not Config.is_valid_value(value, type(self.default_dic[keyword])):
if value is not None:
print(f"Something went wrong. Invalid option: {repr(value)}.")
print(f"Something went wrong. Invalid option: '{value}'.")
try:
value = input('Input new value: ')
except EOFError:
print('\nAborting due to End-of-File character...', file=sys.stderr)
return

value = value.encode().decode('unicode_escape')
self.config_parser['CONSTS'][keyword] = f'"{value}"'
try:
with open(self.config_file, 'w', encoding='utf-8') as conf:
Expand Down

0 comments on commit bf4e196

Please sign in to comment.