User interface : main

Provides the user interface(s) to the punx program.

source code settings

Python Utilities for NeXus HDF5 files

main user interface file

Usage

console> punx -h
usage: punx [-h] [-v]
            {configuration,demonstrate,structure,tree,update,validate} ...

Python Utilities for NeXus HDF5 files version: 0.2.0+9.g31fd4b4.dirty URL:
http://punx.readthedocs.io

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit

subcommand:
  valid subcommands

  {configuration,demonstrate,structure,tree,update,validate}
    configuration       show configuration details of punx
    demonstrate         demonstrate HDF5 file validation
    structure           structure command deprecated. Use ``tree`` instead
    tree                show tree structure of HDF5 or NXDL file
    update              update the local cache of NeXus definitions
    validate            validate a NeXus file

Note: It is only necessary to use the first two (or more) characters of any
subcommand, enough that the abbreviation is unique. Such as: ``demonstrate``
can be abbreviated to ``demo`` or even ``de``.

main()

MyArgumentParser([prog, usage, description, ...])

override standard ArgumentParser to enable shortcut feature

parse_command_line_arguments()

process command line

func_demo(args)

show what punx can do

func_validate(args)

validate the content of a NeXus HDF5 data file of NXDL XML file

func_hierarchy(args)

not implemented yet

func_configuration(args)

show internal configuration of punx

func_tree(args)

print the tree structure of a NeXus HDF5 data file of NXDL XML file

func_update(args)

update or install versions of the NeXus definitions

class punx.main.MyArgumentParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)[source]

override standard ArgumentParser to enable shortcut feature

stretch goal: permit the first two char (or more) of each subcommand to be accepted # ?? http://stackoverflow.com/questions/4114996/python-argparse-nargs-or-depending-on-prior-argument?rq=1

parse_args(args=None, namespace=None)[source]

permit the first two char (or more) of each subcommand to be accepted

punx.main.exit_message(msg, status=None, exit_code=1)[source]

exit this code with a message and a status

Parameters
  • msg (str) – text to be reported

  • status (int) – 0 - 50 (default: ERROR = 40)

  • exit_code (int) – 0: no error, 1: error (default)

punx.main.func_configuration(args)[source]

show internal configuration of punx

punx.main.func_demo(args)[source]

show what punx can do

Internally, runs these commands:

punx validate <source_directory>/data/writer_1_3.hdf5
punx tree <source_directory>/data/writer_1_3.hdf5

If you get an error message that looks like this one (line breaks added here for clarity):

punx.cache.FileNotFound: file does not exist:
/Users/<username>/.config/punx/definitions-master/nxdl.xsd
AND not found in source cache either!  Report this problem to the developer.

then you will need to update your local cache of the NeXus definitions. Use this command to update the local cache:

punx update
punx.main.func_hierarchy(args)[source]

not implemented yet

punx.main.func_structure(args)[source]

deprecated subcommand

punx.main.func_tree(args)[source]

print the tree structure of a NeXus HDF5 data file of NXDL XML file

punx.main.func_update(args)[source]

update or install versions of the NeXus definitions

punx.main.func_validate(args)[source]

validate the content of a NeXus HDF5 data file of NXDL XML file

punx.main.parse_command_line_arguments()[source]

process command line