aboutsummaryrefslogtreecommitdiffstats
path: root/bot/utils/persist.py
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-09-24 18:54:10 +0300
committerGravatar GitHub <[email protected]>2020-09-24 18:54:10 +0300
commit69d2292ec4b3fb2dc83f291ef1ed7bc86eabfd09 (patch)
treeb0c3c0991eef3fc278a0977baf129a7205ff469c /bot/utils/persist.py
parentMerge remote-tracking branch 'origin/tic-tac-toe' into tic-tac-toe (diff)
parentMerge pull request #456 from Anubhav1603/update_dpy (diff)
Merge branch 'master' into tic-tac-toe
Diffstat (limited to 'bot/utils/persist.py')
-rw-r--r--bot/utils/persist.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/bot/utils/persist.py b/bot/utils/persist.py
index d78e5420..1e178569 100644
--- a/bot/utils/persist.py
+++ b/bot/utils/persist.py
@@ -25,13 +25,16 @@ def make_persistent(file_path: Path) -> Path:
as otherwise only one datafile can be persistent and will be returned for
both cases.
+ Ensure that all open files are using explicit appropriate encoding to avoid
+ encoding errors from diffent OS systems.
+
Example Usage:
>>> import json
>>> template_datafile = Path("bot", "resources", "evergreen", "myfile.json")
>>> path_to_persistent_file = make_persistent(template_datafile)
>>> print(path_to_persistent_file)
data/evergreen/myfile.json
- >>> with path_to_persistent_file.open("w+") as f:
+ >>> with path_to_persistent_file.open("w+", encoding="utf8") as f:
>>> data = json.load(f)
"""
# ensure the persistent data directory exists