add get_latest_session_id

This commit is contained in:
Daniel 2023-12-07 19:15:32 +01:00
parent fb7f6c3a37
commit 9a06276554

View file

@ -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