Skip to content

Commit

Permalink
generalised the ignore option in cline
Browse files Browse the repository at this point in the history
now will return None for any type of input, not just Fname
  • Loading branch information
trmrsh committed Jul 23, 2021
1 parent 437bbce commit 80c9bfe
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions hipercam/cline.py
Expand Up @@ -526,8 +526,13 @@ def get_value(
(integers only)
ignore : str
for Fname inputs, this is a value that will cause the checks on
existence of files to be skipped.
a string value that will cause the routine to immediately return
with a None. The idea is to enable ignoring of parameter values
based on checking for None later in the calling code. For Fname
inputs in particular, this skips any checks on the existence of
files. If used, one should put the string needed to match the value
of ignore in the prompt. The usual value used in the hipercam
pipeline is 'none'.
enforce : bool
controls whether "min" and "max" are used to prevent user input
Expand Down Expand Up @@ -651,14 +656,15 @@ def get_value(
else:
value = reply

if value == ignore:
return None

# at this stage we have the value, now try to convert to the right
# type according to the type of 'defval'
try:
if isinstance(defval, Fname):
if value != ignore:
# run Fname checks if the input value does not match
# 'ignore'
value = defval(value)
# run Fname checks
value = defval(value)

elif isinstance(defval, str):
value = str(value)
Expand Down Expand Up @@ -773,11 +779,6 @@ def get_value(
if self._list:
print(param, "=", value)

if isinstance(defval, Fname) and value == ignore:
# return None in this case since this is a
# value to be ignored.
value = None

return value

def get_rest(self):
Expand Down

0 comments on commit 80c9bfe

Please sign in to comment.