41
41
'buildpath' ,
42
42
'containerpath' ,
43
43
'installpath' ,
44
- 'repositorypath' ,
45
44
'sourcepath' ,
46
45
]
47
46
@@ -63,13 +62,14 @@ class DelimitedPathList(click.Path):
63
62
"""Custom Click parameter type for delimited lists."""
64
63
name = 'pathlist'
65
64
66
- def __init__ (self , * args , delimiter = ',' , resolve_full : bool = False , ** kwargs ):
65
+ def __init__ (self , * args , delimiter = ',' , ** kwargs ):
66
+ self .resolve_full = kwargs .setdefault ('resolve_path' , False )
67
67
super ().__init__ (* args , ** kwargs )
68
68
self .delimiter = delimiter
69
- self .resolve_full = resolve_full
69
+ name = self .name
70
+ self .name = f'[{ name } [{ self .delimiter } { name } ]]'
70
71
71
72
def convert (self , value , param , ctx ):
72
- # logging.warning(f"{param=} convert called with `{value=}`, `{type(value)=}`")
73
73
if isinstance (value , str ):
74
74
res = value .split (self .delimiter )
75
75
elif isinstance (value , (list , tuple )):
@@ -78,12 +78,10 @@ def convert(self, value, param, ctx):
78
78
raise click .BadParameter (f"Expected a comma-separated string, got { value } " )
79
79
if self .resolve_full :
80
80
res = [os .path .abspath (v ) for v in res ]
81
- # logging.warning(f"{param=} convert returning `{res=}`")
82
81
return res
83
82
84
83
def shell_complete (self , ctx , param , incomplete ):
85
84
others , last = ([None ] + incomplete .rsplit (self .delimiter , 1 ))[- 2 :]
86
- # logging.warning(f"Shell completion for delimited path list: others={others}, last={last}")
87
85
dir_path , prefix = os .path .split (last )
88
86
dir_path = dir_path or '.'
89
87
# logging.warning(f"Shell completion for delimited path list: dir_path={dir_path}, prefix={prefix}")
@@ -107,11 +105,10 @@ def shell_complete(self, ctx, param, incomplete):
107
105
108
106
class DelimitedString (click .ParamType ):
109
107
"""Custom Click parameter type for delimited strings."""
110
- name = 'strlist'
111
-
112
108
def __init__ (self , * args , delimiter = ',' , ** kwargs ):
113
109
super ().__init__ (* args , ** kwargs )
114
110
self .delimiter = delimiter
111
+ self .name = f'[STR[{ self .delimiter } STR]]'
115
112
116
113
def convert (self , value , param , ctx ):
117
114
if isinstance (value , str ):
@@ -173,20 +170,20 @@ def to_click_option_dec(self):
173
170
174
171
# Manually enforced FILE types
175
172
if self .name in KNOWN_FILEPATH_OPTS :
176
- kwargs ['type' ] = click .Path (exists = True , dir_okay = False , file_okay = True )
173
+ kwargs ['type' ] = click .Path (dir_okay = False , file_okay = True )
177
174
# Manually enforced DIRECTORY types
178
175
elif self .name in KNOWN_DIRPATH_OPTS :
179
- kwargs ['type' ] = click .Path (exists = True , dir_okay = True , file_okay = False )
176
+ kwargs ['type' ] = click .Path (dir_okay = True , file_okay = False )
180
177
# Convert options from easybuild.tools.options
181
178
elif self .type in ['strlist' , 'strtuple' ]:
182
179
kwargs ['type' ] = DelimitedString (delimiter = ',' )
183
- kwargs ['multiple' ] = True
180
+ # kwargs['multiple'] = True
184
181
elif self .type in ['pathlist' , 'pathtuple' ]:
185
182
kwargs ['type' ] = DelimitedPathList (delimiter = os .pathsep )
186
- kwargs ['multiple' ] = True
183
+ # kwargs['multiple'] = True
187
184
elif self .type in ['urllist' , 'urltuple' ]:
188
185
kwargs ['type' ] = DelimitedString (delimiter = '|' )
189
- kwargs ['multiple' ] = True
186
+ # kwargs['multiple'] = True
190
187
elif self .type == 'choice' :
191
188
if self .lst is None :
192
189
raise ValueError (f"Choice type requires a list of choices for option { self .name } " )
@@ -202,7 +199,7 @@ def to_click_option_dec(self):
202
199
if self .default is False or self .default is True :
203
200
kwargs ['is_flag' ] = True
204
201
kwargs ['type' ] = click .BOOL
205
- if self .action in [ 'store_true' , 'store_false' ] :
202
+ if self .default is True :
206
203
decl = f"--{ self .name } /--disable-{ self .name } "
207
204
elif isinstance (self .default , (list , tuple )):
208
205
kwargs ['multiple' ] = True
0 commit comments