diff options
author | 2020-05-24 20:08:51 -0400 | |
---|---|---|
committer | 2020-05-24 20:08:51 -0400 | |
commit | de7e39ab5b0092a637cca91f6bd42b8cf195958e (patch) | |
tree | d8233b4eceb609bd3f3e050ab46ce3c00f6edc13 /bot/utils/persist.py | |
parent | 5/24 - bot exts - updated writing with utf8 encoding (diff) |
5/24 - bot utils - added encoding, and notes for persist
Diffstat (limited to 'bot/utils/persist.py')
-rw-r--r-- | bot/utils/persist.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/bot/utils/persist.py b/bot/utils/persist.py index d78e5420..0b4a60c0 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 encod + 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 |