Try utf-16 if utf-8 fails

This commit is contained in:
Dustin Pianalto 2018-05-09 16:32:11 -08:00
parent e2ed331e5b
commit a90f97129e

View File

@ -45,7 +45,7 @@ def rename_section(cfg, sec, sec_new):
return cfg return cfg
def process_file(in_file, file_type, encoding) -> ConfigParser: def process_file(in_file, file_type) -> ConfigParser:
with open(f'{config_dir}{bot_config_file}') as f: with open(f'{config_dir}{bot_config_file}') as f:
bot_config = json.load(f) bot_config = json.load(f)
ignore_strings = bot_config['ignore_strings'][file_type] ignore_strings = bot_config['ignore_strings'][file_type]
@ -111,6 +111,7 @@ def process_files(z) -> (ConfigParser, ConfigParser, list):
return 0, 0, 0 return 0, 0, 0
elif 'DinoExport' in filename: elif 'DinoExport' in filename:
# Get the contents of all DinoExport_*.ini files loaded into a dict # Get the contents of all DinoExport_*.ini files loaded into a dict
print(filename)
try: try:
with open(f'{path}{filename}', encoding='utf-8') as file: with open(f'{path}{filename}', encoding='utf-8') as file:
dino_data[filename] = process_file(file, 'dino.ini', 'utf-8') dino_data[filename] = process_file(file, 'dino.ini', 'utf-8')