#! /usr/bin/python
'''A tool to pretty print the CTO hardware capabilities and attributes'''

import sys
import getopt
import pprint

import isi.hw.hal as hal
import isi.gconfig as gconfig

#----------------------------------------------------------------------
def hwcapabilities_pprint(verbose=False):
    print '============'
    print 'Capabilities'
    print '============'
    ctx = gconfig.open(hal.gcfg_hwcapabilities).ctx_new()
    hccs = ctx.read('hwcapabilities')
    if verbose:
        for hcc in hccs:
            print ''
            pprint.pprint(hcc)
    else:
        pprint.pprint(hccs[0])

#----------------------------------------------------------------------
def hwattributes_pprint(verbose=False):
    print '=========='
    print 'Attributes'
    print '=========='
    ctx = gconfig.open(hal.gcfg_hwattributes).ctx_new()
    hacs = ctx.read('hwattributes')
    if verbose:
        for hac in hacs:
            print ''
            pprint.pprint(hac)
    else:
        pprint.pprint(hacs[0])

#----------------------------------------------------------------------
def usage():
    usage = (
'''Usage: %s [OPTION] [ARG]

OPTIONS:
    -h, --help      Prints this text

ARGS:
    --verbose       Include default settings in dump
''')

    print usage % (sys.argv[0])

#----------------------------------------------------------------------
def main(argv):
    verbose = False

    try:
        opt, args = getopt.getopt(argv, 'h', ['help', 'verbose'])

    except getopt.GetoptError, err:
        print str(err)
        usage()
        sys.exit(1)

    if opt and len(opt) == 0 and args and len(args) == 0:
        usage()
        sys.exit(1)

    for o, a in opt:
        if o in ('-h', '--help'):
            usage()
            sys.exit(0)
        elif o in ('--verbose'):
            verbose = True

    hwcapabilities_pprint(verbose)
    print ''
    hwattributes_pprint(verbose)
    sys.exit(0)

#----------------------------------------------------------------------
if __name__ == '__main__':
    main(sys.argv[1:])
#! /usr/bin/python
'''A tool to pretty print the CTO hardware capabilities and attributes'''

import sys
import getopt
import pprint

import isi.hw.hal as hal
import isi.gconfig as gconfig

#----------------------------------------------------------------------
def hwcapabilities_pprint(verbose=False):
    print '============'
    print 'Capabilities'
    print '============'
    ctx = gconfig.open(hal.gcfg_hwcapabilities).ctx_new()
    hccs = ctx.read('hwcapabilities')
    if verbose:
        for hcc in hccs:
            print ''
            pprint.pprint(hcc)
    else:
        pprint.pprint(hccs[0])

#----------------------------------------------------------------------
def hwattributes_pprint(verbose=False):
    print '=========='
    print 'Attributes'
    print '=========='
    ctx = gconfig.open(hal.gcfg_hwattributes).ctx_new()
    hacs = ctx.read('hwattributes')
    if verbose:
        for hac in hacs:
            print ''
            pprint.pprint(hac)
    else:
        pprint.pprint(hacs[0])

#----------------------------------------------------------------------
def usage():
    usage = (
'''Usage: %s [OPTION] [ARG]

OPTIONS:
    -h, --help      Prints this text

ARGS:
    --verbose       Include default settings in dump
''')

    print usage % (sys.argv[0])

#----------------------------------------------------------------------
def main(argv):
    verbose = False

    try:
        opt, args = getopt.getopt(argv, 'h', ['help', 'verbose'])

    except getopt.GetoptError, err:
        print str(err)
        usage()
        sys.exit(1)

    if opt and len(opt) == 0 and args and len(args) == 0:
        usage()
        sys.exit(1)

    for o, a in opt:
        if o in ('-h', '--help'):
            usage()
            sys.exit(0)
        elif o in ('--verbose'):
            verbose = True

    hwcapabilities_pprint(verbose)
    print ''
    hwattributes_pprint(verbose)
    sys.exit(0)

#----------------------------------------------------------------------
if __name__ == '__main__':
    main(sys.argv[1:])
