Source code for viiapackage.reporting.helper_functions.find_latest_folder

### ===================================================================================================================
###   FUNTION: find_latest_folder
### ===================================================================================================================
# Copyright ©VIIA 2024

### ===================================================================================================================
###   1. Import modules
### ===================================================================================================================

# General imports
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject


### ===================================================================================================================
###   2. Helper function
### ===================================================================================================================

[docs]def find_latest_folder(project: ViiaProject, file_path: Path): """ This function finds the latest folder in a given path based on the latest version and time an in the name of the folder. For BSC, v001 is used and for TVA, the latest version is utilised. Within this selection the latest timestamp in the folder name is used to find the folder. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - file_path (str): The path of the folder containing the folders from which the latest result folder must be obtained. Output: - The latest result folder for BSC or TVA is returned. Returns None if it could not be found. """ if file_path.exists(): latest_folder = project.viia_get_latest_model_folder(version=project.version, folder=file_path) if latest_folder: return latest_folder.stem else: return None else: return None
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================