Skip to content

Commit

Permalink
Resolves #46. Generates a CC ID if none found in XML.
Browse files Browse the repository at this point in the history
Obeys config.HALT_ON_ERROR. Updates tests.
  • Loading branch information
shidarin committed Jul 5, 2015
1 parent 8050ddd commit 7ac45e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions cdl_convert/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

# cdl_convert imports

from . import collection, correction
from . import config, collection, correction

# ==============================================================================
# EXPORTS
Expand Down Expand Up @@ -247,7 +247,10 @@ def parse_cc(input_file): # pylint: disable=R0912
try:
cc_id = root.attrib['id']
except KeyError:
raise ValueError('No id found on ColorCorrection')
if config.HALT_ON_ERROR:
raise ValueError('No id found on ColorCorrection')
else:
cc_id = None

cdl = correction.ColorCorrection(cc_id)
if file_in:
Expand Down
10 changes: 5 additions & 5 deletions tests/test_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,17 +635,17 @@ def tearDown(self):
#==========================================================================

def testNoId(self):
"""Tests that not finding an id attrib raises ValueError"""
"""Tests that not finding an id attrib works"""

# Build our cc
with tempfile.NamedTemporaryFile(mode='wb', delete=False) as f:
f.write(enc(CC_NO_ID))
self.file = f.name

self.assertRaises(
ValueError,
cdl_convert.parse_cc,
self.file
cc = cdl_convert.parse_cc(self.file)
self.assertEqual(
'001',
cc.id
)

#==========================================================================
Expand Down

0 comments on commit 7ac45e5

Please sign in to comment.