From de7e39ab5b0092a637cca91f6bd42b8cf195958e Mon Sep 17 00:00:00 2001 From: jodth07 Date: Sun, 24 May 2020 20:08:51 -0400 Subject: 5/24 - bot utils - added encoding, and notes for persist --- bot/utils/persist.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bot/utils/persist.py') 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 -- cgit v1.2.3 From 97b667e9c46d4834fd7f55e41fad8fea3c1fb236 Mon Sep 17 00:00:00 2001 From: kwzrd Date: Mon, 25 May 2020 11:31:54 +0200 Subject: Remove accidental extra word from docstring --- bot/utils/persist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot/utils/persist.py') diff --git a/bot/utils/persist.py b/bot/utils/persist.py index 0b4a60c0..1e178569 100644 --- a/bot/utils/persist.py +++ b/bot/utils/persist.py @@ -25,7 +25,7 @@ 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 + Ensure that all open files are using explicit appropriate encoding to avoid encoding errors from diffent OS systems. Example Usage: -- cgit v1.2.3