From 9a062765545937e386c1f8c148b456b2da78546e Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 7 Dec 2023 19:15:32 +0100 Subject: [PATCH] add get_latest_session_id --- pytest_abra/dir_manager.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pytest_abra/dir_manager.py b/pytest_abra/dir_manager.py index 0125522..846d9f6 100644 --- a/pytest_abra/dir_manager.py +++ b/pytest_abra/dir_manager.py @@ -76,3 +76,10 @@ class DirManager: env_file = next(self.ENV_FILES.glob(f"*{search_string}*")) config: dict[str, str] = dotenv_values(env_file) # type: ignore return config + + @staticmethod + def get_latest_session_id(output_dir: Path) -> str: + """returns the name of the newest dir inside of output_dir""" + all_dirs = [d for d in output_dir.iterdir() if d.is_dir()] + newest_dir: Path = max(all_dirs, key=lambda x: x.stat().st_ctime) + return newest_dir.name