-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Reason about stock tools based on ToolSource abstractions.""" | ||
|
||
from lxml.etree import XMLSyntaxError | ||
|
||
# Set GALAXY_INCLUDES_ROOT from tool shed to point this at a Galaxy root | ||
# (once we are running the tool shed from packages not rooted with Galaxy). | ||
import galaxy.tools | ||
from galaxy.tool_util.parser import get_tool_source | ||
from galaxy.util import galaxy_root_path | ||
from galaxy.util.resources import files | ||
|
||
|
||
def stock_tool_paths(): | ||
yield from _walk_directory_for_tools(files(galaxy.tools)) | ||
yield from _walk_directory_for_tools(galaxy_root_path / "test" / "functional" / "tools") | ||
|
||
|
||
def stock_tool_sources(): | ||
for stock_tool_path in stock_tool_paths(): | ||
try: | ||
yield get_tool_source(str(stock_tool_path)) | ||
except XMLSyntaxError: | ||
continue | ||
|
||
|
||
|
||
def _walk_directory_for_tools(path): | ||
if path.is_file() and path.name.endswith(".xml"): | ||
yield path | ||
elif path.is_dir(): | ||
for directory in path.iterdir(): | ||
yield from _walk_directory_for_tools(directory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from galaxy.tools.stock import ( | ||
stock_tool_paths, | ||
stock_tool_sources, | ||
) | ||
|
||
|
||
def test_stock_tool_paths(): | ||
file_names = [f.name for f in list(stock_tool_paths())] | ||
assert "merge_collection.xml" in file_names | ||
assert "meme.xml" in file_names | ||
assert "output_auto_format.xml" in file_names | ||
|
||
|
||
def test_stock_tool_sources(): | ||
tool_source = next(stock_tool_sources()) | ||
assert tool_source.parse_id() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters