### ===================================================================================================================
### VIIA create ontwerpnotitie report
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, Dict, Optional, List
from datetime import datetime
from pathlib import Path
# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.fem_tools import fem_create_folder
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
### ===================================================================================================================
### 2. Functions to create ontwerpnotitie report
### ===================================================================================================================
[docs]def viia_create_ontwerpnotitie_report(
project: ViiaProject, template_locations: Dict[str, str], report_data: Optional[dict],
output_folder: Optional[Path] = None) -> List[Path]:
"""
This function creates ontwerpnotitie report.
Input:
- project (obj): VIIA project object containing collections of fem objects and project variables.
- template_locations (dict): Dictionary which stores the path of all requested template files.
- report_data (dict): Dictionary which includes all project specific data for reporting.
- output_folder (Path): Optional input for location where to create the report. Default value is None,
indicating the default location is used. In normal production objects do not change this!
Output:
- The requested report is generated with the information of the object in py-memory, databases and local
(image)-files. It is saved in the 'Ontwerpnotitie Report' folder of the working folder.
"""
# Create or check the location where the report is generated
if output_folder is None:
# Create sub folder
fem_create_folder('Ontwerpnotitie Report', ref_folder=project.workfolder_location)
report_location = project.workfolder_location / 'Ontwerpnotitie Report'
else:
if isinstance(output_folder, str):
output_folder = Path(output_folder)
report_location = output_folder
# Check if output-folder is created
if not report_location.exists():
raise FileNotFoundError("ERROR: The specified output-folder does not exist, please check input.")
# Create report
generated_reports = []
for key, value in template_locations.items():
time_reference = datetime.now().strftime('%Y%m%d%H%M%S')
output_document_name = f'VIIA_{project.name}_Ontwerpnotitie_Rapport_{time_reference}.docx'
generated_reports.append(project.create_report(
template_file=project.viia_settings.project_specific_package_location / template_locations[key],
data=report_data,
output_file=report_location / output_document_name,
render_images=True))
project.write_log(
f"Finished processing report {output_document_name}. Generated report can be found in '{report_location}'")
return generated_reports
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================