MCPcopy Create free account
hub / github.com/PyTables/PyTables / main

Function main

tables/scripts/ptdump.py:156–197  ·  view source on GitHub ↗

Implement the main CLI interface.

()

Source from the content-addressed store, hash-verified

154
155
156def main():
157 """Implement the main CLI interface."""
158 parser = _get_parser()
159
160 args = parser.parse_args(namespace=options)
161
162 # Get the options
163 if isinstance(args.rng, str):
164 try:
165 options.rng = eval("slice(" + args.rng + ")")
166 except Exception:
167 parser.error("Error when getting the range parameter.")
168 else:
169 args.dump = 1
170
171 # Catch the files passed as the last arguments
172 src = args.src.rsplit(":", 1)
173 if len(src) == 1:
174 filename, nodename = src[0], "/"
175 else:
176 filename, nodename = src
177 if nodename == "":
178 # case where filename == "filename:" instead of "filename:/"
179 nodename = "/"
180
181 try:
182 h5file = tb.open_file(filename, "r")
183 except Exception as e:
184 return f"Cannot open input file: {e}"
185
186 with h5file:
187 # Check whether the specified node is a group or a leaf
188 nodeobject = h5file.get_node(nodename)
189 if isinstance(nodeobject, tb.group.Group):
190 # Close the file again and reopen using the root_uep
191 dump_group(nodeobject, args.sort)
192 elif isinstance(nodeobject, tb.leaf.Leaf):
193 # If it is not a Group, it must be a Leaf
194 dump_leaf(nodeobject)
195 else:
196 # This should never happen
197 print("Unrecognized object:", nodeobject)

Callers

nothing calls this directly

Calls 4

dump_groupFunction · 0.85
dump_leafFunction · 0.85
_get_parserFunction · 0.70
get_nodeMethod · 0.45

Tested by

no test coverage detected