<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> from __future__ import absolute_import <EOL> import argparse <EOL> import operator <EOL> from tables . file import open_file <EOL> from tables . group import Group <EOL> from tables . leaf import Leaf <EOL> from tables . table import Table , Column <EOL> from tables . unimplemented import UnImplemented <EOL> import six <EOL> from six . moves import range <EOL> options = argparse . Namespace ( <EOL> rng = slice ( None ) , <EOL> showattrs = <NUM_LIT:0> , <EOL> verbose = <NUM_LIT:0> , <EOL> dump = <NUM_LIT:0> , <EOL> colinfo = <NUM_LIT:0> , <EOL> idxinfo = <NUM_LIT:0> , <EOL> ) <EOL> def dump_leaf ( leaf ) : <EOL> if options . verbose : <EOL> print ( repr ( leaf ) ) <EOL> else : <EOL> print ( str ( leaf ) ) <EOL> if options . showattrs : <EOL> print ( "<STR_LIT:U+0020>" + repr ( leaf . attrs ) ) <EOL> if options . dump and not isinstance ( leaf , UnImplemented ) : <EOL> print ( "<STR_LIT>" ) <EOL> if options . rng . start is None : <EOL> start = <NUM_LIT:0> <EOL> else : <EOL> start = options . rng . start <EOL> if options . rng . stop is None : <EOL> if leaf . shape != ( ) : <EOL> stop = leaf . shape [ <NUM_LIT:0> ] <EOL> else : <EOL> stop = options . rng . stop <EOL> if options . rng . step is None : <EOL> step = <NUM_LIT:1> <EOL> else : <EOL> step = options . rng . step <EOL> if leaf . shape == ( ) : <EOL> print ( "<STR_LIT>" % ( leaf [ ( ) ] ) ) <EOL> else : <EOL> for i in range ( start , stop , step ) : <EOL> print ( "<STR_LIT>" % ( i , leaf [ i ] ) ) <EOL> if isinstance ( leaf , Table ) and options . colinfo : <EOL> for colname in leaf . colnames : <EOL> print ( repr ( leaf . cols . _f_col ( colname ) ) ) <EOL> if isinstance ( leaf , Table ) and options . idxinfo : <EOL> for colname in leaf . colnames : <EOL> col = leaf . cols . _f_col ( colname ) <EOL> if isinstance ( col , Column ) and col . index is not None : <EOL> idx = col . index <EOL> print ( repr ( idx ) ) <EOL> def dump_group ( pgroup , sort = False ) : <EOL> node_kinds = pgroup . _v_file . _node_kinds [ <NUM_LIT:1> : ] <EOL> what = pgroup . _f_walk_groups ( ) <EOL> if sort : <EOL> what = sorted ( what , key = operator . attrgetter ( '<STR_LIT>' ) ) <EOL> for group in what : <EOL> print ( str ( group ) ) <EOL> if options . showattrs : <EOL> print ( "<STR_LIT:U+0020>" + repr ( group . _v_attrs ) ) <EOL> for kind in node_kinds : <EOL> for node in group . _f_list_nodes ( kind ) : <EOL> if options . verbose or options . dump : <EOL> dump_leaf ( node ) <EOL> else : <EOL> print ( str ( node ) ) <EOL> def _get_parser ( ) : <EOL> parser = argparse . ArgumentParser ( <EOL> description = '''<STR_LIT>''' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT:-c>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '''<STR_LIT>''' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '''<STR_LIT>''' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '''<STR_LIT>''' , <EOL> ) <EOL> parser . add_argument ( '<STR_LIT:src>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> return parser <EOL> def main ( ) : <EOL> parser = _get_parser ( ) <EOL> args = parser . parse_args ( namespace = options ) <EOL> if isinstance ( args . rng , six . string_types ) : <EOL> try : <EOL> options . rng = eval ( "<STR_LIT>" + args . rng + "<STR_LIT:)>" ) <EOL> except Exception : <EOL> parser . error ( "<STR_LIT>" ) <EOL> else : <EOL> args . dump = <NUM_LIT:1> <EOL> src = args . src . split ( '<STR_LIT::>' ) <EOL> if len ( src ) == <NUM_LIT:1> : <EOL> filename , nodename = src [ <NUM_LIT:0> ] , "<STR_LIT:/>" <EOL> else : <EOL> filename , nodename = src <EOL> if nodename == "<STR_LIT>" : <EOL> nodename = "<STR_LIT:/>" <EOL> try : <EOL> h5file = open_file ( filename , '<STR_LIT:r>' ) <EOL> except Exception as e : <EOL> return '<STR_LIT>' + str ( e ) <EOL> with h5file : <EOL> nodeobject = h5file . get_node ( nodename ) <EOL> if isinstance ( nodeobject , Group ) : <EOL> dump_group ( nodeobject , args . sort ) <EOL> elif isinstance ( nodeobject , Leaf ) : <EOL> dump_leaf ( nodeobject ) <EOL> else : <EOL> print ( "<STR_LIT>" , nodeobject ) </s>
