Ignore:
Timestamp:
03/05/24 17:20:06 (13 months ago)
Author:
jdquinn
Message:

CHG: Corrections to how test suites are parsed under Python

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/test/NightlyRun/IdFromString.py

    r27202 r28129  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
     2
     3from GetAvailableTestIds import *
    24from IdToName import IdToName
    35import os
     
    810
    911def IdFromString(string, verbose=False):
    10     """
    11     IDFROMSTRING - output ids from a given string
    12         Usage:
    13             ids = IdFromString(string)
    14         Examples:
    15             ids = IdFromString('Parallel')
    16             ids = IdFromString('79North')
    17             ids = IdFromString(' * ')
     12    """IdFromString - output ids from a given string
     13
     14    Usage:
     15        ids = IdFromString(string)
     16   
     17    Examples:
     18        ids = IdFromString('Dakota')
     19        ids = IdFromString('Slc')
     20        ids = IdFromString(' * ')
    1821    """
    1922
    20 #Check input
     23    # Check input
    2124    if not isinstance(string, str):
    2225        raise TypeError('IdFromString error message: input argument is not a string.')
     
    2427    string = string.replace('"', '')
    2528
    26 #Get the test ids and names and scan for matches
    27 
     29    # Get the test ids and names and scan for matches
    2830    ids = []
    2931    idnames = []
    30     flist = [f for f in os.listdir('.') if re.match('test[0-9]+.py', f)] # File name must follow the format "test<integer>.py"
    31     list_ids = [int(re.search(r'\d+',file.split('.')[0]).group()) for file in flist] # Retrieve test IDs
    32     for i in list_ids:
     32    available_test_ids = GetAvailableTestIds()
     33    for i in available_test_ids:
    3334        name = IdToName(i)
    3435        if (string == ' * ') or (name is not None and string in name):
     
    3637            idnames.append(name)
    3738
    38 #Return if no test found
     39    # Return if no test found
    3940    if not ids:
    4041        print("No test matches '%s'." % string)
    4142        return ids
    4243
    43 #Display names
     44    # Display names
    4445    if verbose:
    4546        idnames = [i for _, i in sorted(zip(ids, idnames), key=lambda pair: pair[0])]
Note: See TracChangeset for help on using the changeset viewer.