Added jp2h __repr__ method. #133

This commit is contained in:
John Evans 2013-10-23 06:41:31 -04:00
commit 18818495d2
2 changed files with 18 additions and 3 deletions

View file

@ -1102,11 +1102,15 @@ class JP2HeaderBox(Jp2kBox):
box : list
List of boxes contained in this superbox.
"""
def __init__(self, length=0, offset=-1):
def __init__(self, box=[], length=0, offset=-1):
Jp2kBox.__init__(self, box_id='jp2h', longname='JP2 Header')
self.length = length
self.offset = offset
self.box = []
self.box = box
def __repr__(self):
msg = "glymur.jp2box.JP2HeaderBox(box={0})".format(self.box)
return msg
def __str__(self):
msg = Jp2kBox.__str__(self)

View file

@ -755,9 +755,20 @@ class TestRepr(unittest.TestCase):
self.assertEqual(newbox.channel_type, (COLOR, COLOR, COLOR))
self.assertEqual(newbox.association, (RED, GREEN, BLUE))
def test_imageheader_box(self):
def test_jp2header_box(self):
"""Verify __repr__ method on ihdr box."""
ihdr = ImageHeaderBox(100, 200, num_components=3)
colr = ColourSpecificationBox(colorspace=glymur.core.SRGB)
jp2h = JP2HeaderBox(box=[ihdr, colr])
newbox = eval(repr(jp2h))
self.assertEqual(newbox.box_id, 'jp2h')
self.assertEqual(newbox.box[0].box_id, 'ihdr')
self.assertEqual(newbox.box[1].box_id, 'colr')
def test_imageheader_box(self):
"""Verify __repr__ method on jhdr box."""
ihdr = ImageHeaderBox(100, 200, num_components=3)
newbox = eval(repr(ihdr))
self.assertEqual(newbox.height, 100)
self.assertEqual(newbox.width, 200)