Skip to content

Commit

Permalink
Adds --halt flag to trigger HALT_ON_ERROR behavior. Closes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
shidarin committed May 10, 2014
1 parent fa55d61 commit 76d629f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cdl_convert/cdl_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,16 @@ def parse_args():
"accepted. Defaults to a .cc XML. Supported output formats are: " # pylint: disable=C0330
"{outputs}".format(outputs=str(OUTPUT_FORMATS.keys())) # pylint: disable=C0330
)
parser.add_argument(
"--halt",
action='store_true',
help="turns off exception handling default behavior. Turn this on if "
"you want the conversion process to fail and not continue,"
"rather than relying on default behavior for bad values. Examples "
"are clipping negative values to 0.0 for Slope, Power and "
"Saturation, and automatically generating a new id for a "
"ColorCorrect if no or a bad id is given."
)

args = parser.parse_args()

Expand Down Expand Up @@ -2299,6 +2309,10 @@ def parse_args():
else:
args.output = ['cc', ]

if args.halt:
global HALT_ON_ERROR
HALT_ON_ERROR = True

return args

# ==============================================================================
Expand Down
18 changes: 18 additions & 0 deletions tests/test_cdl_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,24 @@ def testNoProvidedOutput(self):
args.output
)

#==========================================================================

def testHaltOnError(self):
"""Tests that providing the --halt flag triggers HALT_ON_ERROR"""
self.assertFalse(
cdl_convert.HALT_ON_ERROR
)

sys.argv = ['scriptname', 'inputFile', '--halt']

cdl_convert.parse_args()

self.assertTrue(
cdl_convert.HALT_ON_ERROR
)

cdl_convert.HALT_ON_ERROR = False

# main() ======================================================================


Expand Down

0 comments on commit 76d629f

Please sign in to comment.