Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci_find_tools: add --group_tools #1008

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions planemo/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ def filter_paths(ctx, raw_paths, path_type="repo", **kwds):
return chunked_paths


def group_paths(paths):
repos = {}
for path in paths:
repo = os.path.split(path)[0]
if repo not in repos:
repos[repo] = []
repos[repo].append(path)
return [" ".join(repos[_]) for _ in repos]


def print_path_list(paths, **kwds):
with io.open_file_or_standard_output(kwds["output"], "w") as f:
for path in paths:
Expand Down
14 changes: 12 additions & 2 deletions planemo/commands/cmd_ci_find_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
import click

from planemo import options
from planemo.ci import filter_paths, print_path_list
from planemo.ci import (
filter_paths,
group_paths,
print_path_list
)
from planemo.cli import command_function
from planemo.tools import is_tool_load_error, yield_tool_sources_on_paths
from planemo.tools import (
is_tool_load_error,
yield_tool_sources_on_paths
)


@click.command('ci_find_tools')
@options.shed_project_arg()
@options.ci_find_options()
@options.ci_group_tools_option()
@command_function
def cli(ctx, paths, **kwds):
"""Find all tools in one or more directories.
Expand All @@ -26,4 +34,6 @@ def cli(ctx, paths, **kwds):
tool_paths.append(tool_path)

paths = filter_paths(ctx, tool_paths, path_type="file", **kwds)
if kwds.get('group_tools', False):
paths = group_paths(paths)
print_path_list(paths, **kwds)
8 changes: 8 additions & 0 deletions planemo/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,14 @@ def ci_chunk_count_option():
)


def ci_group_tools_option():
return planemo_option(
"--group_tools",
is_flag=True,
help="Group tools of the same repository on a single line."
)


def ci_chunk_option():
return planemo_option(
"--chunk",
Expand Down