From 8e6e244ebfe56fd13e255596842c98093a2a5cd2 Mon Sep 17 00:00:00 2001 From: jeong jinmyeong Date: Sat, 22 Nov 2025 20:14:37 +0900 Subject: [PATCH] read wildcard unicode first --- modules/impact/wildcards.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/impact/wildcards.py b/modules/impact/wildcards.py index 7fa94a59..8435ea02 100644 --- a/modules/impact/wildcards.py +++ b/modules/impact/wildcards.py @@ -360,11 +360,11 @@ def get_wildcard_value(key): def load_txt_wildcard(file_path): """Load a .txt wildcard file""" try: - with open(file_path, 'r', encoding="ISO-8859-1") as f: + with open(file_path, 'r', encoding="UTF-8") as f: lines = f.read().splitlines() return [x for x in lines if x.strip() and not x.strip().startswith('#')] except (yaml.reader.ReaderError, UnicodeDecodeError): - with open(file_path, 'r', encoding="UTF-8", errors="ignore") as f: + with open(file_path, 'r', encoding="ISO-8859-1") as f: lines = f.read().splitlines() return [x for x in lines if x.strip() and not x.strip().startswith('#')] @@ -374,10 +374,10 @@ def load_yaml_wildcard(file_path, key_prefix=''): global loaded_wildcards try: - with open(file_path, 'r', encoding="ISO-8859-1") as f: + with open(file_path, 'r', encoding="UTF-8") as f: yaml_data = yaml.load(f, Loader=yaml.FullLoader) except (yaml.reader.ReaderError, UnicodeDecodeError): - with open(file_path, 'r', encoding="UTF-8", errors="ignore") as f: + with open(file_path, 'r', encoding="ISO-8859-1") as f: yaml_data = yaml.load(f, Loader=yaml.FullLoader) if not yaml_data: @@ -480,11 +480,11 @@ def read_wildcard_dict(wildcard_path, on_demand=False): else: # Load data immediately (original behavior) try: - with open(file_path, 'r', encoding="ISO-8859-1") as f: + with open(file_path, 'r', encoding="UTF-8") as f: lines = f.read().splitlines() wildcard_dict[key] = [x for x in lines if x.strip() and not x.strip().startswith('#')] - except yaml.reader.ReaderError: - with open(file_path, 'r', encoding="UTF-8", errors="ignore") as f: + except (yaml.reader.ReaderError, UnicodeDecodeError): + with open(file_path, 'r', encoding="ISO-8859-1") as f: lines = f.read().splitlines() wildcard_dict[key] = [x for x in lines if x.strip() and not x.strip().startswith('#')] elif file.endswith('.yaml') or file.endswith('.yml'): @@ -501,10 +501,10 @@ def read_wildcard_dict(wildcard_path, on_demand=False): else: # Load data immediately (original behavior) try: - with open(file_path, 'r', encoding="ISO-8859-1") as f: + with open(file_path, 'r', encoding="UTF-8") as f: yaml_data = yaml.load(f, Loader=yaml.FullLoader) - except yaml.reader.ReaderError: - with open(file_path, 'r', encoding="UTF-8", errors="ignore") as f: + except (yaml.reader.ReaderError, UnicodeDecodeError): + with open(file_path, 'r', encoding="ISO-8859-1") as f: yaml_data = yaml.load(f, Loader=yaml.FullLoader) for k, v in yaml_data.items():