Permalink
Browse files

Normalize special handling for galaxy_root in ~/.planemo.yml.

  • Loading branch information...
jmchilton committed Jun 22, 2017
1 parent 1cccfd9 commit 8a608e0a0fd4b6a987e5eedeb953b44de3ca5157
Showing with 13 additions and 8 deletions.
  1. +10 −6 planemo/config.py
  2. +0 −2 planemo/galaxy/config.py
  3. +3 −0 planemo/options.py
@@ -19,7 +19,7 @@


def _default_callback(
default, use_global_config=False, resolve_path=False,
default, use_global_config=False, resolve_path=False, extra_global_config_vars=[],
):

def callback(ctx, param, value):
@@ -33,6 +33,7 @@ def callback(ctx, param, value):
planemo_ctx,
param,
use_global_config=use_global_config,
extra_global_config_vars=extra_global_config_vars,
)

if result is VALUE_UNSET:
@@ -51,13 +52,14 @@ def callback(ctx, param, value):
return callback


def _find_default(ctx, param, use_global_config):
def _find_default(ctx, param, use_global_config, extra_global_config_vars):
if use_global_config:
global_config = ctx.global_config
global_config_key = "default_%s" % param.name
if global_config_key in global_config:
default_value = global_config[global_config_key]
return default_value, OptionSource.global_config
global_config_keys = ["default_%s" % param.name] + extra_global_config_vars
for global_config_key in global_config_keys:
if global_config_key in global_config:
default_value = global_config[global_config_key]
return default_value, OptionSource.global_config

return VALUE_UNSET, None

@@ -73,6 +75,7 @@ def planemo_option(*args, **kwargs):
option_type = kwargs.get("type", None)
use_global_config = kwargs.pop("use_global_config", False)
use_env_var = kwargs.pop("use_env_var", False)
extra_global_config_vars = kwargs.pop("extra_global_config_vars", [])

default_specified = "default" in kwargs
default = None
@@ -87,6 +90,7 @@ def callback(ctx, param, value):
result = _default_callback(
default,
use_global_config=use_global_config,
extra_global_config_vars=extra_global_config_vars,
resolve_path=resolve_path,
)(ctx, param, value)

@@ -977,8 +977,6 @@ def _find_galaxy_root(ctx, **kwds):
galaxy_root = kwds.get(root_prop, None)
if galaxy_root:
return galaxy_root
elif ctx.global_config.get(root_prop, None):
return ctx.global_config[root_prop]
else:
par_dir = os.getcwd()
while True:
@@ -122,6 +122,7 @@ def galaxy_root_option():
return planemo_option(
"--galaxy_root",
use_global_config=True,
extra_global_config_vars=["galaxy_root"],
use_env_var=True,
type=click.Path(exists=True, file_okay=False, resolve_path=True),
help="Root of development galaxy directory to execute command with.",
@@ -143,6 +144,8 @@ def galaxy_cwl_root_option():
return planemo_option(
"--cwl_galaxy_root",
use_global_config=True,
extra_global_config_vars=["cwl_galaxy_root"],
use_env_var=True,
type=click.Path(exists=True, file_okay=False, resolve_path=True),
help=("Root of development galaxy directory to execute command with"
" (must be branch of Galaxy with CWL support, this option"

0 comments on commit 8a608e0

Please sign in to comment.