Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/planemo/test/data.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
| author | shellac |
|---|---|
| date | Mon, 22 Mar 2021 18:12:50 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:4f3585e2f14b |
|---|---|
| 1 """Utilities related to reasoning about test data.""" | |
| 2 | |
| 3 import os | |
| 4 | |
| 5 | |
| 6 def find_test_data_directory(tool_paths, **kwds): | |
| 7 path = "." | |
| 8 if len(tool_paths) > 0: | |
| 9 path = tool_paths[0] | |
| 10 | |
| 11 # Find test data directory associated with path. | |
| 12 test_data = kwds.get("test_data", None) | |
| 13 if test_data: | |
| 14 return os.path.abspath(test_data) | |
| 15 else: | |
| 16 test_data = search_tool_path_for(path, "test-data") | |
| 17 if test_data: | |
| 18 return test_data | |
| 19 | |
| 20 | |
| 21 def search_tool_path_for(path, target, extra_paths=[]): | |
| 22 """Check for presence of a target in different artifact directories.""" | |
| 23 if not os.path.isdir(path): | |
| 24 tool_dir = os.path.dirname(path) | |
| 25 else: | |
| 26 tool_dir = path | |
| 27 possible_dirs = [tool_dir, "."] + extra_paths | |
| 28 for possible_dir in possible_dirs: | |
| 29 possible_path = os.path.join(possible_dir, target) | |
| 30 if os.path.exists(possible_path): | |
| 31 return os.path.abspath(possible_path) | |
| 32 return None | |
| 33 | |
| 34 | |
| 35 __all__ = ( | |
| 36 "search_tool_path_for", | |
| 37 ) |
