From 115f3de3ecf3c831079edddc7c6f106c3f6f4832 Mon Sep 17 00:00:00 2001 From: j-c-cook Date: Mon, 22 Aug 2022 17:33:03 -0500 Subject: [PATCH 1/3] Fix _default_name for compressed files --- can/io/logger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/can/io/logger.py b/can/io/logger.py index b50825d3f..74ed4ea1c 100644 --- a/can/io/logger.py +++ b/can/io/logger.py @@ -345,11 +345,11 @@ def _default_name(self) -> StringPathLike: """Generate the default rotation filename.""" path = pathlib.Path(self.base_filename) new_name = ( - path.stem + path.parts[-1].split(".")[0] + "_" + datetime.now().strftime("%Y-%m-%dT%H%M%S") + "_" + f"#{self.rollover_count:03}" - + path.suffix + + "".join(pathlib.Path(self.base_filename).suffixes[-2:]) ) return str(path.parent / new_name) From 3c29ba443d2ee45a7a1df292aa861ac99d052f2a Mon Sep 17 00:00:00 2001 From: j-c-cook Date: Sat, 27 Aug 2022 11:36:52 -0500 Subject: [PATCH 2/3] Handle a filepath that contains "." prior to stem --- can/io/logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/io/logger.py b/can/io/logger.py index 74ed4ea1c..db72f76cd 100644 --- a/can/io/logger.py +++ b/can/io/logger.py @@ -345,7 +345,7 @@ def _default_name(self) -> StringPathLike: """Generate the default rotation filename.""" path = pathlib.Path(self.base_filename) new_name = ( - path.parts[-1].split(".")[0] + path.stem.split(".")[0] + "_" + datetime.now().strftime("%Y-%m-%dT%H%M%S") + "_" From 50026765b477d2a558696d5a076902996f637207 Mon Sep 17 00:00:00 2001 From: j-c-cook Date: Sat, 27 Aug 2022 11:40:23 -0500 Subject: [PATCH 3/3] Reuse local path variable --- can/io/logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/io/logger.py b/can/io/logger.py index db72f76cd..478651953 100644 --- a/can/io/logger.py +++ b/can/io/logger.py @@ -350,6 +350,6 @@ def _default_name(self) -> StringPathLike: + datetime.now().strftime("%Y-%m-%dT%H%M%S") + "_" + f"#{self.rollover_count:03}" - + "".join(pathlib.Path(self.base_filename).suffixes[-2:]) + + "".join(path.suffixes[-2:]) ) return str(path.parent / new_name)