view talosnames/main.py @ 7:68d2384b0a52

switch to command parser
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 10 Jul 2012 14:24:25 -0700
parents 90e477181404
children 20c42ae0f7b7
line wrap: on
line source

#!/usr/bin/env python

"""
correlate names of talos
"""

import api
import sys
import optparse
from commandparser import CommandParser
from pprint import pprint

class TalosNamesCLI(CommandParser):
    def __init__(self):
        self.api = api.TalosNames()

    def graphserver(self, *names):
        if not names:
            pass

def main(args=sys.argv[1:]):

    # parse command line options
    usage = '%prog [options] [name]'
    class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
        """description formatter for console script entry point"""
        def format_description(self, description):
            if description:
                return description.strip() + '\n'
            else:
                return ''
    parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
    options, args = parser.parse_args(args)

    # get the names from graphserver
    names = api.TalosNames()

    if not args:
        args = [None]
    for arg in args:
        for name, graphserver_name in names(arg):
            print '%s : %s' % (name, graphserver_name)
        print

if __name__ == '__main__':

    parser = CommandParser(TalosNamesCLI)
    parser.invoke(sys.argv[1:])