Checking for ICC profile that is None. #183
This commit is contained in:
parent
df651a66d8
commit
77d2ab194a
3 changed files with 25 additions and 6 deletions
|
|
@ -359,13 +359,16 @@ class ColourSpecificationBox(Jp2kBox):
|
|||
else:
|
||||
# 2.7 has trouble pretty-printing ordered dicts so we just have
|
||||
# to print as a regular dict in this case.
|
||||
if sys.hexversion < 0x03000000:
|
||||
icc_profile = dict(self.icc_profile)
|
||||
if self.icc_profile is None:
|
||||
msg += '\n ICC Profile: None'
|
||||
else:
|
||||
icc_profile = self.icc_profile
|
||||
dispvalue = pprint.pformat(icc_profile)
|
||||
lines = [' ' * 8 + y for y in dispvalue.split('\n')]
|
||||
msg += '\n ICC Profile:\n{0}'.format('\n'.join(lines))
|
||||
if sys.hexversion < 0x03000000:
|
||||
icc_profile = dict(self.icc_profile)
|
||||
else:
|
||||
icc_profile = self.icc_profile
|
||||
dispvalue = pprint.pformat(icc_profile)
|
||||
lines = [' ' * 8 + y for y in dispvalue.split('\n')]
|
||||
msg += '\n ICC Profile:\n{0}'.format('\n'.join(lines))
|
||||
|
||||
return msg
|
||||
|
||||
|
|
|
|||
|
|
@ -582,3 +582,8 @@ issue_182_cmap = """Component Mapping Box (cmap) @ (130, 24)
|
|||
Component 0 ==> palette column 0
|
||||
Component 1 ==> palette column 0
|
||||
Component 2 ==> 2"""
|
||||
|
||||
issue_183_colr = """Colour Specification Box (colr) @ (62, 12)
|
||||
Method: restricted ICC profile
|
||||
Precedence: 0
|
||||
ICC Profile: None"""
|
||||
|
|
|
|||
|
|
@ -920,6 +920,17 @@ class TestPrinting(unittest.TestCase):
|
|||
actual = fake_out.getvalue().strip()
|
||||
self.assertEqual(actual, fixtures.issue_182_cmap)
|
||||
|
||||
def test_issue183(self):
|
||||
filename = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2')
|
||||
|
||||
with warnings.catch_warnings():
|
||||
# Ignore warning about bad pclr box.
|
||||
warnings.simplefilter("ignore")
|
||||
jp2 = Jp2k(filename)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(jp2.box[2].box[1])
|
||||
actual = fake_out.getvalue().strip()
|
||||
self.assertEqual(actual, fixtures.issue_183_colr)
|
||||
|
||||
@unittest.skipIf(sys.hexversion < 0x03000000,
|
||||
"Ordered dicts not printing well in 2.7")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue