Suppressing warnings until metadata printing is done. Closes #96
This commit is contained in:
parent
a2103c18b1
commit
c98737a72c
1 changed files with 20 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Entry point for jp2dump script.
|
||||
"""
|
||||
import warnings
|
||||
|
||||
from .jp2k import Jp2k
|
||||
|
||||
|
|
@ -15,8 +16,22 @@ def jp2dump(filename, codestream=False):
|
|||
codestream : optional, logical scalar
|
||||
Whether or not to dump codestream contents.
|
||||
"""
|
||||
j = Jp2k(filename)
|
||||
if codestream:
|
||||
print(j.get_codestream(header_only=False))
|
||||
else:
|
||||
print(j)
|
||||
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))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue