diff --git a/glymur/__init__.py b/glymur/__init__.py index f39d6ef..eb0139c 100644 --- a/glymur/__init__.py +++ b/glymur/__init__.py @@ -7,7 +7,6 @@ from glymur import version __version__ = version.version from .jp2k import Jp2k -from .jp2dump import jp2dump from .jp2box import get_printoptions, set_printoptions from .jp2box import get_parseoptions, set_parseoptions diff --git a/glymur/command_line.py b/glymur/command_line.py index 82b5292..62b9057 100644 --- a/glymur/command_line.py +++ b/glymur/command_line.py @@ -1,10 +1,15 @@ -#!/usr/bin/env python - +""" +Entry point for console script jp2dump. +""" import argparse import sys -from . import jp2dump, set_printoptions +import warnings +from . import Jp2k, set_printoptions def main(): + """ + Entry point for console script jp2dump. + """ description='Print JPEG2000 metadata.' parser = argparse.ArgumentParser(description=description) @@ -45,5 +50,22 @@ def main(): print_full_codestream = True filename = args.filename - jp2dump(args.filename, codestream=print_full_codestream) + with warnings.catch_warnings(record=True) as wctx: + + # JP2 metadata can be extensive, so don't print any warnings until we + # are done with the metadata. + j = Jp2k(filename) + if print_full_codestream: + print(j.get_codestream(header_only=False)) + else: + print(j) + + # Re-emit any warnings that may have been suppressed. + if len(wctx) > 0: + print("\n") + for warning in wctx: + print("{0}:{1}: {2}: {3}".format(warning.filename, + warning.lineno, + warning.category.__name__, + warning.message)) diff --git a/glymur/jp2dump.py b/glymur/jp2dump.py deleted file mode 100644 index c0f0f7f..0000000 --- a/glymur/jp2dump.py +++ /dev/null @@ -1,36 +0,0 @@ -""" -Entry point for jp2dump script. -""" -import warnings - -from .jp2k import Jp2k - - -def jp2dump(filename, codestream=False): - """Prints JPEG2000 metadata. - - Parameters - ---------- - filename : string - The input JPEG2000 file. - codestream : optional, logical scalar - Whether or not to dump codestream contents. - """ - with warnings.catch_warnings(record=True) as wctx: - - # JP2 metadata can be extensive, so don't print any warnings until we - # are done with the metadata. - j = Jp2k(filename) - if codestream: - print(j.get_codestream(header_only=False)) - else: - print(j) - - # Re-emit any warnings that may have been suppressed. - if len(wctx) > 0: - print("\n") - for warning in wctx: - print("{0}:{1}: {2}: {3}".format(warning.filename, - warning.lineno, - warning.category.__name__, - warning.message))