Improved warning message when brand is not proper. #232
This commit is contained in:
parent
a79e234f8a
commit
bf65a00f28
2 changed files with 7 additions and 5 deletions
|
|
@ -1241,8 +1241,10 @@ class FileTypeBox(Jp2kBox):
|
||||||
def _validate(self, writing=False):
|
def _validate(self, writing=False):
|
||||||
"""Validate the box before writing to file."""
|
"""Validate the box before writing to file."""
|
||||||
if self.brand not in ['jp2 ', 'jpx ']:
|
if self.brand not in ['jp2 ', 'jpx ']:
|
||||||
msg = "The file type brand must be either 'jp2 ' or 'jpx '."
|
msg = "The file type brand was '{0}'. "
|
||||||
self._dispatch_validation_error(msg, writing=writing)
|
msg += "It should be either 'jp2 ' or 'jpx '."
|
||||||
|
self._dispatch_validation_error(msg.format(self.brand),
|
||||||
|
writing=writing)
|
||||||
valid_cls = ['jp2 ', 'jpx ', 'jpxb']
|
valid_cls = ['jp2 ', 'jpx ', 'jpxb']
|
||||||
for item in self.compatibility_list:
|
for item in self.compatibility_list:
|
||||||
if item not in valid_cls:
|
if item not in valid_cls:
|
||||||
|
|
|
||||||
|
|
@ -814,9 +814,9 @@ class TestJp2kOpjDataRootWarnings(unittest.TestCase):
|
||||||
"""Should warn in case of bad ftyp brand."""
|
"""Should warn in case of bad ftyp brand."""
|
||||||
filename = opj_data_file('input/nonregression/edf_c2_1000290.jp2')
|
filename = opj_data_file('input/nonregression/edf_c2_1000290.jp2')
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
warnings.simplefilter('always')
|
warnings.simplefilter('always')
|
||||||
jp2 = Jp2k(filename)
|
jp2 = Jp2k(filename)
|
||||||
self.assertTrue(issubclass(w[0].category, UserWarning))
|
self.assertTrue(issubclass(w[0].category, UserWarning))
|
||||||
|
|
||||||
def test_invalid_approximation(self):
|
def test_invalid_approximation(self):
|
||||||
"""Should warn in case of invalid approximation."""
|
"""Should warn in case of invalid approximation."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue