Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/planemo/test/data.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author | shellac |
---|---|
date | Thu, 14 May 2020 14:56:58 -0400 |
parents | 26e78fe6e8c4 |
children |
comparison
equal
deleted
inserted
replaced
1:75ca89e9b81c | 2:6af9afd405e9 |
---|---|
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 ) |