From dc2b2bda15447c89dc3a693f703bc4edaa5defc9 Mon Sep 17 00:00:00 2001 From: John Evans Date: Sun, 4 Jan 2015 21:39:14 -0500 Subject: [PATCH] the main header will be printed by default --- glymur/command_line.py | 16 +++++++++------- glymur/jp2box.py | 13 ++++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/glymur/command_line.py b/glymur/command_line.py index ff442f3..0836108 100644 --- a/glymur/command_line.py +++ b/glymur/command_line.py @@ -13,23 +13,25 @@ def main(): Entry point for console script jp2dump. """ - description = 'Print JPEG2000 metadata.' - parser = argparse.ArgumentParser(description=description) + kwargs = {'description': 'Print JPEG2000 metadata.', + 'formatter_class': argparse.ArgumentDefaultsHelpFormatter} + parser = argparse.ArgumentParser(**kwargs) parser.add_argument('-x', '--noxml', - help='Suppress XML.', + help='suppress XML', action='store_true') parser.add_argument('-s', '--short', - help='Only print box id, offset, and length.', + help='only print box id, offset, and length', action='store_true') - chelp = 'Level of codestream information. 0 suppressed all details, ' - chelp += '1 prints headers, 2 prints the full codestream' + chelp = 'Level of codestream information. 0 suppresses all details, ' + chelp += '1 prints the main header, 2 prints the full codestream.' parser.add_argument('-c', '--codestream', help=chelp, + metavar='LEVEL', nargs=1, type=int, - default=[0]) + default=[1]) parser.add_argument('filename') diff --git a/glymur/jp2box.py b/glymur/jp2box.py index e29df28..ba204a4 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -1040,10 +1040,11 @@ class ContiguousCodestreamBox(Jp2kBox): msg = Jp2kBox.__str__(self) if _printoptions['short'] is True: return msg - if _printoptions['codestream'] is False: + if _printoptions['siz']: + msg += '\n' + self._indent(str(self.main_header.segment[1]), + indent_level=4) return msg - msg += '\n Main header:' for segment in self.main_header.segment: msg += '\n' + self._indent(str(segment), indent_level=8) @@ -3360,7 +3361,7 @@ def get_parseoptions(): """ return _parseoptions -_printoptions = {'short': False, 'xml': True, 'codestream': True} +_printoptions = {'short': False, 'xml': True, 'siz': True} def set_printoptions(**kwargs): @@ -3377,8 +3378,10 @@ def set_printoptions(**kwargs): xml : bool, optional When False, printing of the XML contents of any XML boxes or UUID XMP boxes is suppressed. - codestream : bool, optional - When False, printing of the codestream contents is suppressed. + siz : bool, optional + When True, only the SIZ segment is printed. When False, the entire + codestream is printed. This option has no effect when the 'short' + option is set to True. See also --------