fix the file read

there may appear a error:
UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 379: illegal multibyte sequence
This commit is contained in:
shaohua.zhang 2020-08-27 14:57:02 +08:00 committed by GitHub
parent efa97b6939
commit f27c147fd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -89,13 +89,13 @@ def load_config(file_path):
merge_config(default_config)
_, ext = os.path.splitext(file_path)
assert ext in ['.yml', '.yaml'], "only support yaml files for now"
merge_config(yaml.load(open(file_path), Loader=yaml.Loader))
merge_config(yaml.load(open(file_path, 'rb'), Loader=yaml.Loader))
assert "reader_yml" in global_config['Global'],\
"absence reader_yml in global"
reader_file_path = global_config['Global']['reader_yml']
_, ext = os.path.splitext(reader_file_path)
assert ext in ['.yml', '.yaml'], "only support yaml files for reader"
merge_config(yaml.load(open(reader_file_path), Loader=yaml.Loader))
merge_config(yaml.load(open(reader_file_path, 'rb'), Loader=yaml.Loader))
return global_config