From b3f4c621b0da6f07973d7a0695d546a5c60ca370 Mon Sep 17 00:00:00 2001 From: lb584 <lb584@cam.ac.uk> Date: Thu, 29 Aug 2024 10:24:29 +0100 Subject: [PATCH] updating comments --- ews/coordinator/utils/jobstatus.py | 4 ++-- ews/coordinator/utils/processor_utils.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ews/coordinator/utils/jobstatus.py b/ews/coordinator/utils/jobstatus.py index 740cd42..ba01bf9 100644 --- a/ews/coordinator/utils/jobstatus.py +++ b/ews/coordinator/utils/jobstatus.py @@ -12,8 +12,8 @@ class Jobstatus: Context manager to determine and change status of a job based on status file in a given directory. - Only possible status values are 'SUCCESS', 'INPROGRESS', 'HELD', 'WARNING' - and 'ERROR'. + Only possible status values are 'SUCCESS', 'INPROGRESS', 'HELD', 'WARNING', + 'SUCCESS_WITH_WARNING', 'SUCCESS_WITH_ERROR' and 'ERROR'. Use jobStatus.reset(status) to change the current status file. diff --git a/ews/coordinator/utils/processor_utils.py b/ews/coordinator/utils/processor_utils.py index a8792ab..75a2eff 100644 --- a/ews/coordinator/utils/processor_utils.py +++ b/ews/coordinator/utils/processor_utils.py @@ -127,6 +127,17 @@ def open_and_check_config(configFile) -> dict: def parse_json_file_with_tokens(file_path: str, tokens: dict = None) -> dict: + """ + parses a json file, replacing any tokens with values from the tokens dict. Tokens are marked as ${token_name} in the + json file. The tokens dict should be a dictionary of key value pairs where the key is the token and the value is the + value to replace the token with. This function can be called with None for the tokens argument, resulting in a simple + json file parse. + + :param file_path: + :param tokens: + :return: + """ + with open(file_path, 'r') as file: file_string: str = file.read() file.seek(0) # reset the index to read again -- GitLab