Skip to content

Commit

Permalink
make metadata printing more uniform
Browse files Browse the repository at this point in the history
  • Loading branch information
esc committed May 29, 2014
1 parent 92ce0c2 commit 0ed7d75
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
10 changes: 7 additions & 3 deletions bloscpack/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ def process_nthread_arg(args):
(args.nthreads, 's' if args.nthreads > 1 else ''))


def log_metadata(metadata):
log.normal("Metadata:")
log.normal(pprint.pformat(metadata, indent=4))


class BloscPackCustomFormatter(argparse.HelpFormatter):
""" Custom HelpFormatter.
Expand Down Expand Up @@ -462,7 +467,7 @@ def main():
try:
metadata = unpack_file(in_file, out_file)
if metadata:
log.normal("Metadata is:\n'%s'" % metadata)
log_metadata(metadata)
except FormatVersionMismatch as fvm:
log.error(fvm.message)
except ChecksumMismatch as csm:
Expand Down Expand Up @@ -507,8 +512,7 @@ def main():
log.normal("'offsets':")
log.normal("[%s,...]" % (",".join(str(o) for o in offsets[:5])))
if metadata is not None:
log.normal("'metadata':")
log.normal(pprint.pformat(metadata, indent=4))
log_metadata(metadata)
log.normal(metadata_header.pformat())

else: # pragma: no cover
Expand Down
9 changes: 6 additions & 3 deletions test_cmdline/test_metadata.cram
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add metadata to the file:
blpk: max_app_chunks: 1530
blpk: 'offsets':
blpk: [14192,169364,311687,472289,628926,...]
blpk: 'metadata':
blpk: Metadata:
blpk: { u'container': u'numpy',
blpk: u'dtype': u'<f8',
blpk: u'order': u'C',
Expand All @@ -42,8 +42,11 @@ Add metadata to the file:
blpk: meta_comp_size: 62.0B (62B)
blpk: user_codec: ''
$ blpk decompress data.dat.blp data.dat.dcmp
blpk: Metadata is:
blpk: '{u'dtype': u'<f8', u'shape': [20000000], u'container': u'numpy', u'order': u'C'}'
blpk: Metadata:
blpk: { u'container': u'numpy',
blpk: u'dtype': u'<f8',
blpk: u'order': u'C',
blpk: u'shape': [20000000]}

Clean up:

Expand Down
14 changes: 10 additions & 4 deletions test_cmdline/test_verbose_debug.cram
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ Get more information using --verbose, but with metadata:
blpk: read compressed metadata of size: '62'
blpk: output file size: 152.59M
blpk: decompression ratio: 9.420032
blpk: Metadata is:
blpk: '{u'dtype': u'<f8', u'shape': [20000000], u'container': u'numpy', u'order': u'C'}'
blpk: Metadata:
blpk: { u'container': u'numpy',
blpk: u'dtype': u'<f8',
blpk: u'order': u'C',
blpk: u'shape': [20000000]}
blpk: done
$ rm data.dat.blp data.dat.dcmp

Expand Down Expand Up @@ -304,8 +307,11 @@ Try using --debug with metadata:
blpk: chunk handled, in: 228.35K (233834B) out: 2.59M (2713600B)
blpk: output file size: 152.59M
blpk: decompression ratio: 9.428965
blpk: Metadata is:
blpk: '{u'dtype': u'<f8', u'shape': [20000000], u'container': u'numpy', u'order': u'C'}'
blpk: Metadata:
blpk: { u'container': u'numpy',
blpk: u'dtype': u'<f8',
blpk: u'order': u'C',
blpk: u'shape': [20000000]}
blpk: done
$ rm data.dat.blp data.dat.dcmp
Check that directory is clean.
Expand Down

0 comments on commit 0ed7d75

Please sign in to comment.