From 7d7309fed43378c6b36f6fb27c5791594e5e3d38 Mon Sep 17 00:00:00 2001 From: Julius <juliusflorstedt@gmail.com> Date: Mon, 17 Mar 2025 10:59:19 +0100 Subject: [PATCH] file write extension --- plot_serializer/serializer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plot_serializer/serializer.py b/plot_serializer/serializer.py index 023e96b..6955dee 100644 --- a/plot_serializer/serializer.py +++ b/plot_serializer/serializer.py @@ -418,7 +418,9 @@ class Serializer: if self._written_to_file: raise NotImplementedError("You can only write the figure into the JSON once! Multiple tries were attempted") if isinstance(file, str): - os.makedirs(os.path.dirname(file), exist_ok=True) + directory = os.path.dirname(file) + if directory: + os.makedirs(directory, exist_ok=True) with open(file, "w") as file: self.write_json_file(file) else: -- GitLab