Skip to content

Commit 8a608e0

Browse files
committed
Normalize special handling for galaxy_root in ~/.planemo.yml.
1 parent 1cccfd9 commit 8a608e0

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

planemo/config.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
def _default_callback(
22-
default, use_global_config=False, resolve_path=False,
22+
default, use_global_config=False, resolve_path=False, extra_global_config_vars=[],
2323
):
2424

2525
def callback(ctx, param, value):
@@ -33,6 +33,7 @@ def callback(ctx, param, value):
3333
planemo_ctx,
3434
param,
3535
use_global_config=use_global_config,
36+
extra_global_config_vars=extra_global_config_vars,
3637
)
3738

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

5354

54-
def _find_default(ctx, param, use_global_config):
55+
def _find_default(ctx, param, use_global_config, extra_global_config_vars):
5556
if use_global_config:
5657
global_config = ctx.global_config
57-
global_config_key = "default_%s" % param.name
58-
if global_config_key in global_config:
59-
default_value = global_config[global_config_key]
60-
return default_value, OptionSource.global_config
58+
global_config_keys = ["default_%s" % param.name] + extra_global_config_vars
59+
for global_config_key in global_config_keys:
60+
if global_config_key in global_config:
61+
default_value = global_config[global_config_key]
62+
return default_value, OptionSource.global_config
6163

6264
return VALUE_UNSET, None
6365

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

7780
default_specified = "default" in kwargs
7881
default = None
@@ -87,6 +90,7 @@ def callback(ctx, param, value):
8790
result = _default_callback(
8891
default,
8992
use_global_config=use_global_config,
93+
extra_global_config_vars=extra_global_config_vars,
9094
resolve_path=resolve_path,
9195
)(ctx, param, value)
9296

planemo/galaxy/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,6 @@ def _find_galaxy_root(ctx, **kwds):
977977
galaxy_root = kwds.get(root_prop, None)
978978
if galaxy_root:
979979
return galaxy_root
980-
elif ctx.global_config.get(root_prop, None):
981-
return ctx.global_config[root_prop]
982980
else:
983981
par_dir = os.getcwd()
984982
while True:

planemo/options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def galaxy_root_option():
122122
return planemo_option(
123123
"--galaxy_root",
124124
use_global_config=True,
125+
extra_global_config_vars=["galaxy_root"],
125126
use_env_var=True,
126127
type=click.Path(exists=True, file_okay=False, resolve_path=True),
127128
help="Root of development galaxy directory to execute command with.",
@@ -143,6 +144,8 @@ def galaxy_cwl_root_option():
143144
return planemo_option(
144145
"--cwl_galaxy_root",
145146
use_global_config=True,
147+
extra_global_config_vars=["cwl_galaxy_root"],
148+
use_env_var=True,
146149
type=click.Path(exists=True, file_okay=False, resolve_path=True),
147150
help=("Root of development galaxy directory to execute command with"
148151
" (must be branch of Galaxy with CWL support, this option"

0 commit comments

Comments
 (0)