diff --git a/setup.py b/setup.py index 1f10c44ae..86517d67e 100644 --- a/setup.py +++ b/setup.py @@ -142,6 +142,8 @@ def run(self): fail_if = sos.actions:fail_if warn_if = sos.actions:warn_if stop_if = sos.actions:stop_if +done_if = sos.actions:done_if +skip_if = sos.actions:skip_if download = sos.actions:download run = sos.actions:run diff --git a/src/sos/actions.py b/src/sos/actions.py index 57e13d616..2ef6574df 100644 --- a/src/sos/actions.py +++ b/src/sos/actions.py @@ -622,6 +622,22 @@ def stop_if(expr, msg='', no_output=False): raise StopInputGroup(msg=msg, keep_output=not no_output) return 0 +@SoS_Action(acceptable_args=['expr', 'msg']) +def done_if(expr, msg=''): + '''Assuming that output has already been generated and stop + executing the rest of the substep''' + if expr: + raise StopInputGroup(msg=msg, keep_output=True) + return 0 + +@SoS_Action(acceptable_args=['expr', 'msg', 'no_output']) +def skip_if(expr, msg=''): + '''Skip the current substep and set _output to empty. Output + will be removed if already generated.''' + if expr: + raise StopInputGroup(msg=msg, keep_output=False) + return 0 + # # download file with progress bar #