From 0fa10c8e0b740cbe773e71bec7d0674e3d6e47ac Mon Sep 17 00:00:00 2001 From: Anry Das Date: Thu, 3 Apr 2025 10:17:27 +0300 Subject: [PATCH] Improved files reading - added encoding --- config_file.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config_file.py b/config_file.py index 718fb9b..a32ff89 100755 --- a/config_file.py +++ b/config_file.py @@ -16,7 +16,7 @@ def read_config(name): raise Exception("Wrong file type") def read_json(name): - with open(name, 'r') as f: + with open(name, 'r', encoding='utf-8') as f: j_conf = json.load(f) conf = {} for key, value in j_conf.items(): @@ -25,7 +25,7 @@ def read_json(name): def read_prop(filepath, sep='=', comment_char='#'): conf = {} - with open(filepath, "rt") as f: + with open(filepath, "rt", encoding='utf-8') as f: for line in f: l = line.strip() if l and not l.startswith(comment_char): @@ -37,7 +37,7 @@ def read_prop(filepath, sep='=', comment_char='#'): def read_yaml(name): conf = {} - with open(name, 'r') as f: + with open(name, 'r', encoding='utf-8') as f: y_conf = yaml.safe_load(f) for key, value in y_conf.items(): conf[key] = value