Changeset 28129 for issm/trunk-jpl/test/NightlyRun/IdFromString.py
- Timestamp:
- 03/05/24 17:20:06 (13 months ago)
- 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 3 from GetAvailableTestIds import * 2 4 from IdToName import IdToName 3 5 import os … … 8 10 9 11 def 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(' * ') 18 21 """ 19 22 20 #Check input23 # Check input 21 24 if not isinstance(string, str): 22 25 raise TypeError('IdFromString error message: input argument is not a string.') … … 24 27 string = string.replace('"', '') 25 28 26 #Get the test ids and names and scan for matches 27 29 # Get the test ids and names and scan for matches 28 30 ids = [] 29 31 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: 33 34 name = IdToName(i) 34 35 if (string == ' * ') or (name is not None and string in name): … … 36 37 idnames.append(name) 37 38 38 #Return if no test found39 # Return if no test found 39 40 if not ids: 40 41 print("No test matches '%s'." % string) 41 42 return ids 42 43 43 #Display names44 # Display names 44 45 if verbose: 45 46 idnames = [i for _, i in sorted(zip(ids, idnames), key=lambda pair: pair[0])]
Note:
See TracChangeset
for help on using the changeset viewer.