From 5d1f51af6c3bf679f770a4e7c1fae09ba81fc925 Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Thu, 8 Jun 2023 14:16:50 +0200 Subject: [PATCH] simplify create_log_file_names using fsrings --- mpsd-software-environment.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py index 4fcd65f..3f6b33f 100755 --- a/mpsd-software-environment.py +++ b/mpsd-software-environment.py @@ -12,7 +12,6 @@ import time from pathlib import Path from typing import List, Tuple, Union import re -from string import Template # If 'rich' is available ("pip install rich" or "apt-get install python3-rich"), # then use coloured output, otherwise proceed as before @@ -38,14 +37,7 @@ call_date_iso = ( config_vars = { # kept inside the mpsd_release folder "cmd_log_file": "script_execution_summary.log", - # Placeholder installer log file name, placed at mpsd_microarch/logs - "installer_log_template": Template( - "${mpsd_release}_${mpsd_microarch}_${date}_APEX_${action}.log" - ), - # Placeholder build log file name, placed at mpsd_microarch/logs - "build_log_template": Template( - "${mpsd_release}_${mpsd_microarch}_${date}_BUILD_${toolchain}_${action}.log" - ), + # Metadata tags "metadata_tag_open": "!<meta>", "metadata_tag_close": "</meta>!", "spack_environments_repo": "https://gitlab.gwdg.de/mpsd-cs/spack-environments.git", @@ -96,20 +88,16 @@ def create_log_file_names( if toolchain: # if toolchain is given, then we build the build_log_file_name if action in ["install", "remove"]: - log_template = config_vars["build_log_template"] + log_file_name = ( + f"{mpsd_release}_{mpsd_microarch}_{date}_BUILD_{toolchain}_{action}.log" + ) else: return None else: # if toolchain is not given, then we build the installer_log_file_name - log_template = config_vars["installer_log_template"] - - return log_template.substitute( - mpsd_release=mpsd_release, - mpsd_microarch=mpsd_microarch, - date=date, - action=action, - toolchain=toolchain, - ) + log_file_name = f"{mpsd_release}_{mpsd_microarch}_{date}_APEX_{action}.log" + + return log_file_name def log_metadata(key: str, value: str) -> None: -- GitLab