Mercurial > repos > shellac > sam_consensus_v3
diff env/lib/python3.9/site-packages/planemo/runnable_resolve.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/env/lib/python3.9/site-packages/planemo/runnable_resolve.py Mon Mar 22 18:12:50 2021 +0000 @@ -0,0 +1,37 @@ +import os + +from planemo.galaxy.profiles import translate_alias +from planemo.galaxy.workflows import GALAXY_WORKFLOWS_PREFIX +from planemo.tools import uri_to_path +from .runnable import ( + for_path, + for_uri, +) + + +def for_runnable_identifier(ctx, runnable_identifier, kwds, temp_path=None, return_all=False): + """Convert URI, path, or alias into Runnable.""" + # could be a URI, path, or alias + current_profile = kwds.get('profile') + runnable_identifier = translate_alias(ctx, runnable_identifier, current_profile) + if not runnable_identifier.startswith(GALAXY_WORKFLOWS_PREFIX): + runnable_identifier = uri_to_path(ctx, runnable_identifier) + if os.path.exists(runnable_identifier): + runnable = for_path(runnable_identifier, temp_path=temp_path, return_all=return_all) + else: # assume galaxy workflow id + if not runnable_identifier.startswith(GALAXY_WORKFLOWS_PREFIX): + runnable_identifier = f"{GALAXY_WORKFLOWS_PREFIX}{runnable_identifier}" + runnable = for_uri(runnable_identifier) + return runnable + + +def for_runnable_identifiers(ctx, runnable_identifiers, kwds, temp_path=None): + """Convert lists of URIs, paths, and/or aliases into Runnables.""" + runnables = [] + for r in runnable_identifiers: + runnable = for_runnable_identifier(ctx, r, kwds, temp_path=temp_path, return_all=True) + if isinstance(runnable, list): + runnables.extend(runnable) + else: + runnables.append(runnable) + return runnables