def choose_target(args: argparse.Namespace, tool: Process, loading_context: LoadingContext) -> Optional[Process]:
    'Walk the Workflow, extract the subset matches all the args.targets.'
    if (loading_context.loader is None):
        raise Exception('loading_context.loader cannot be None')
    if isinstance(tool, Workflow):
        url = urllib.parse.urlparse(tool.tool['id'])
        if url.fragment:
            extracted = get_subgraph([((tool.tool['id'] + '/') + r) for r in args.target], tool, loading_context)
        else:
            extracted = get_subgraph([loading_context.loader.fetcher.urljoin(tool.tool['id'], ('#' + r)) for r in args.target], tool, loading_context)
    else:
        _logger.error('Can only use --target on Workflows')
        return None
    if isinstance(loading_context.loader.idx, MutableMapping):
        loading_context.loader.idx[extracted['id']] = extracted
        tool = make_tool(extracted['id'], loading_context)
    else:
        raise Exception('Missing loading_context.loader.idx!')
    return tool
Walk the Workflow, extract the subset matches all the args.targets.
def choose_target(args: argparse.Namespace, tool: Process, loading_context: LoadingContext) -> Optional[Process]:
    
    if (loading_context.loader is None):
        raise Exception('loading_context.loader cannot be None')
    if isinstance(tool, Workflow):
        url = urllib.parse.urlparse(tool.tool['id'])
        if url.fragment:
            extracted = get_subgraph([((tool.tool['id'] + '/') + r) for r in args.target], tool, loading_context)
        else:
            extracted = get_subgraph([loading_context.loader.fetcher.urljoin(tool.tool['id'], ('#' + r)) for r in args.target], tool, loading_context)
    else:
        _logger.error('Can only use --target on Workflows')
        return None
    if isinstance(loading_context.loader.idx, MutableMapping):
        loading_context.loader.idx[extracted['id']] = extracted
        tool = make_tool(extracted['id'], loading_context)
    else:
        raise Exception('Missing loading_context.loader.idx!')
    return tool