From 256ebbf9eca4f7e56bdafa1ed031bb43060fd7e6 Mon Sep 17 00:00:00 2001 From: jevans Date: Mon, 26 Jan 2015 19:32:24 -0500 Subject: [PATCH] Refactor ChannelDefinitionBox __str__ method --- glymur/jp2box.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/glymur/jp2box.py b/glymur/jp2box.py index 8aac99a..5e06280 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -630,19 +630,26 @@ class ChannelDefinitionBox(Jp2kBox): self._dispatch_validation_error(msg, writing=writing) def __str__(self): - msg = Jp2kBox.__str__(self) + title = Jp2kBox.__str__(self) if _printoptions['short'] is True: - return msg + return title + lst = [] for j in range(len(self.association)): color_type_string = _COLOR_TYPE_MAP_DISPLAY[self.channel_type[j]] if self.association[j] == 0: assn = 'whole image' else: assn = str(self.association[j]) - msg += '\n Channel {0} ({1}) ==> ({2})' - msg = msg.format(self.index[j], color_type_string, assn) - return msg + text = 'Channel {0} ({1}) ==> ({2})'.format(self.index[j], + color_type_string, + assn) + lst.append(text) + + text = '\n'.join(lst) + text = self._indent(text) + text = '\n'.join([title, text]) + return text def __repr__(self): msg = "glymur.jp2box.ChannelDefinitionBox("