mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Read and write config in UTF-8
This commit is contained in:
parent
ba3d299c05
commit
a99ddaa0cc
@ -120,7 +120,7 @@ class Config:
|
|||||||
# Using config.read_file instead of config.read because config.read
|
# Using config.read_file instead of config.read because config.read
|
||||||
# would just ignore a missing file and carry on.
|
# would just ignore a missing file and carry on.
|
||||||
try:
|
try:
|
||||||
with open(path) as f:
|
with open(path, encoding="utf-8") as f:
|
||||||
parser.read_file(f, source=str(path))
|
parser.read_file(f, source=str(path))
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
raise ConfigLoadError(path, "File does not exist")
|
raise ConfigLoadError(path, "File does not exist")
|
||||||
@ -154,12 +154,12 @@ class Config:
|
|||||||
try:
|
try:
|
||||||
# x = open for exclusive creation, failing if the file already
|
# x = open for exclusive creation, failing if the file already
|
||||||
# exists
|
# exists
|
||||||
with open(path, "x") as f:
|
with open(path, "x", encoding="utf-8") as f:
|
||||||
self._parser.write(f)
|
self._parser.write(f)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
print("That file already exists.")
|
print("That file already exists.")
|
||||||
if asyncio.run(prompt_yes_no("Overwrite it?", default=False)):
|
if asyncio.run(prompt_yes_no("Overwrite it?", default=False)):
|
||||||
with open(path, "w") as f:
|
with open(path, "w", encoding="utf-8") as f:
|
||||||
self._parser.write(f)
|
self._parser.write(f)
|
||||||
else:
|
else:
|
||||||
raise ConfigDumpError(path, "File already exists")
|
raise ConfigDumpError(path, "File already exists")
|
||||||
|
Loading…
Reference in New Issue
Block a user