Improved files reading - added encoding
This commit is contained in:
parent
6254b1809a
commit
0fa10c8e0b
@ -16,7 +16,7 @@ def read_config(name):
|
|||||||
raise Exception("Wrong file type")
|
raise Exception("Wrong file type")
|
||||||
|
|
||||||
def read_json(name):
|
def read_json(name):
|
||||||
with open(name, 'r') as f:
|
with open(name, 'r', encoding='utf-8') as f:
|
||||||
j_conf = json.load(f)
|
j_conf = json.load(f)
|
||||||
conf = {}
|
conf = {}
|
||||||
for key, value in j_conf.items():
|
for key, value in j_conf.items():
|
||||||
@ -25,7 +25,7 @@ def read_json(name):
|
|||||||
|
|
||||||
def read_prop(filepath, sep='=', comment_char='#'):
|
def read_prop(filepath, sep='=', comment_char='#'):
|
||||||
conf = {}
|
conf = {}
|
||||||
with open(filepath, "rt") as f:
|
with open(filepath, "rt", encoding='utf-8') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
l = line.strip()
|
l = line.strip()
|
||||||
if l and not l.startswith(comment_char):
|
if l and not l.startswith(comment_char):
|
||||||
@ -37,7 +37,7 @@ def read_prop(filepath, sep='=', comment_char='#'):
|
|||||||
|
|
||||||
def read_yaml(name):
|
def read_yaml(name):
|
||||||
conf = {}
|
conf = {}
|
||||||
with open(name, 'r') as f:
|
with open(name, 'r', encoding='utf-8') as f:
|
||||||
y_conf = yaml.safe_load(f)
|
y_conf = yaml.safe_load(f)
|
||||||
for key, value in y_conf.items():
|
for key, value in y_conf.items():
|
||||||
conf[key] = value
|
conf[key] = value
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user