From c8fe9ed7763ed46e90e3feca56a2688a3dc2269f Mon Sep 17 00:00:00 2001 From: John Evans Date: Thu, 24 Oct 2013 09:29:45 -0400 Subject: [PATCH] Added proper repr support for association box. #133 --- glymur/jp2box.py | 8 ++++++-- glymur/test/test_jp2box.py | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/glymur/jp2box.py b/glymur/jp2box.py index 8303981..6466a63 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -1061,11 +1061,15 @@ class AssociationBox(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='asoc', longname='Association') self.length = length self.offset = offset - self.box = [] + self.box = box + + def __repr__(self): + msg = "glymur.jp2box.AssociationBox(box={0})".format(self.box) + return msg def __str__(self): msg = Jp2kBox.__str__(self) diff --git a/glymur/test/test_jp2box.py b/glymur/test/test_jp2box.py index b82af47..bf14789 100644 --- a/glymur/test/test_jp2box.py +++ b/glymur/test/test_jp2box.py @@ -780,6 +780,13 @@ class TestRepr(unittest.TestCase): self.assertFalse(newbox.colorspace_unknown) self.assertFalse(newbox.ip_provided) + def test_association_box(self): + """Verify __repr__ method on asoc box.""" + asoc = glymur.jp2box.AssociationBox() + newbox = eval(repr(asoc)) + self.assertEqual(newbox.box_id, 'asoc') + self.assertEqual(len(newbox.box), 0) + def test_codestreamheader_box(self): """Verify __repr__ method on jpch box.""" jpch = glymur.jp2box.CodestreamHeaderBox()