From 8c0aa748e5aa9ed5188c07dd2a17dbcd2bce171d Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 16 Nov 2022 15:59:50 -0700 Subject: [PATCH] fixed broken doc util logic from bad PR merge --- metplus/util/config_util.py | 19 +------------------ metplus/util/doc_util.py | 22 ++-------------------- metplus/util/string_manip.py | 24 +++++++++++++++++++++++- 3 files changed, 26 insertions(+), 39 deletions(-) mode change 100644 => 100755 metplus/util/doc_util.py diff --git a/metplus/util/config_util.py b/metplus/util/config_util.py index 0a08aeff1..fa835bb6c 100644 --- a/metplus/util/config_util.py +++ b/metplus/util/config_util.py @@ -1,28 +1,11 @@ import os import re -from .constants import LOWER_TO_WRAPPER_NAME -from .string_manip import getlist +from .string_manip import getlist, get_wrapper_name from .string_template_substitution import do_string_sub from .system_util import mkdir_p -def get_wrapper_name(process_name): - """! Determine name of wrapper from string that may not contain the correct - capitalization, i.e. Pcp-Combine translates to PCPCombine - - @param process_name string that was listed in the PROCESS_LIST - @returns name of wrapper (without 'Wrapper' at the end) and None if - name cannot be determined - """ - lower_process = (process_name.replace('-', '').replace('_', '') - .replace(' ', '').lower()) - if lower_process in LOWER_TO_WRAPPER_NAME.keys(): - return LOWER_TO_WRAPPER_NAME[lower_process] - - return None - - def get_process_list(config): """!Read process list, Extract instance string if specified inside parenthesis. Remove dashes/underscores and change to lower case, diff --git a/metplus/util/doc_util.py b/metplus/util/doc_util.py old mode 100644 new mode 100755 index a223f07f7..812f9dc05 --- a/metplus/util/doc_util.py +++ b/metplus/util/doc_util.py @@ -4,28 +4,10 @@ import os try: - from .config_util import get_wrapper_name + from .string_manip import get_wrapper_name except ImportError: sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) - from config_util import get_wrapper_name - - -def get_wrapper_name(process_name): - """! Determine name of wrapper from string that may not contain the correct - capitalization, i.e. Pcp-Combine translates to PCPCombine - - @param process_name string that was listed in the PROCESS_LIST - @returns name of wrapper (without 'Wrapper' at the end) and None if - name cannot be determined - """ - lower_process = (process_name.replace('-', '') - .replace('_', '') - .replace(' ', '') - .lower()) - if lower_process in LOWER_TO_WRAPPER_NAME.keys(): - return LOWER_TO_WRAPPER_NAME[lower_process] - - return None + from string_manip import get_wrapper_name def print_doc_text(tool_name, input_dict): diff --git a/metplus/util/string_manip.py b/metplus/util/string_manip.py index d93bda5ad..07f4610c8 100644 --- a/metplus/util/string_manip.py +++ b/metplus/util/string_manip.py @@ -4,12 +4,34 @@ Description: METplus utility to handle string manipulation """ +import sys +import os import re from csv import reader import random import string -from .constants import VALID_COMPARISONS +try: + from .constants import VALID_COMPARISONS, LOWER_TO_WRAPPER_NAME +except ImportError: + sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) + from constants import VALID_COMPARISONS, LOWER_TO_WRAPPER_NAME + + +def get_wrapper_name(process_name): + """! Determine name of wrapper from string that may not contain the correct + capitalization, i.e. Pcp-Combine translates to PCPCombine + + @param process_name string that was listed in the PROCESS_LIST + @returns name of wrapper (without 'Wrapper' at the end) and None if + name cannot be determined + """ + lower_process = (process_name.replace('-', '').replace('_', '') + .replace(' ', '').lower()) + if lower_process in LOWER_TO_WRAPPER_NAME.keys(): + return LOWER_TO_WRAPPER_NAME[lower_process] + + return None def remove_quotes(input_string):