parameters: (argv)
return_statement: return 0
docstring: Main routine.
  
    Args:
      argv: list of arguments
  
    Returns:
      exit code, 0 for normal exit.
docstring_summary: Main routine.
docstring_tokens: Main routine .
function: def Main(argv):
    """Main routine.
  
    Args:
      argv: list of arguments
  
    Returns:
      exit code, 0 for normal exit.
    """
    # Parse args
    parser = optparse.OptionParser()
    parser.add_option(
        '-i', '--input', dest='inputs', type='string', action='append',
        metavar='FILE',
        help='read LCOV input from FILE')
    parser.add_option(
        '-r', '--root', dest='roots', type='string', action='append',
        metavar='ROOT[=ALTNAME]',
        help='add ROOT directory, optionally map in coverage results as ALTNAME')
    parser.add_option(
        '-c', '--config', dest='configs', type='string', action='append',
        metavar='FILE',
        help='read settings from configuration FILE')
    parser.add_option(
        '-a', '--addfiles', dest='addfiles', type='string', action='append',
        metavar='PATH',
        help='add files from PATH to coverage data')
    parser.add_option(
        '-t', '--tree', dest='tree', action='store_true',
        help='print tree of code coverage by group')
    parser.add_option(
        '-u', '--uninstrumented', dest='uninstrumented', action='store_true',
        help='list uninstrumented files')
    parser.add_option(
        '-m', '--html', dest='html_out', type='string', metavar='PATH',
        help='write HTML output to PATH')
    parser.add_option(
        '-b', '--base_url', dest='base_url', type='string', metavar='URL',
        help='include URL in base tag of HTML output')
  
    parser.set_defaults(
        inputs=[],
        roots=[],
        configs=[],
        addfiles=[],
        tree=False,
        html_out=None,
    )
  
    options = parser.parse_args(args=argv)[0]
  
    cov = Coverage()
  
    # Set root directories for coverage
    for root_opt in options.roots:
      if '=' in root_opt:
        cov.AddRoot(*root_opt.split('='))
      else:
        cov.AddRoot(root_opt)
  
    # Read config files
    for config_file in options.configs:
      cov.ParseConfig(config_file, lcov_queue=options.inputs,
                      addfiles_queue=options.addfiles)
  
    # Parse lcov files
    for input_filename in options.inputs:
      cov.ParseLcovFile(input_filename)
  
    # Add missing files
    for add_path in options.addfiles:
      cov.AddFiles(add_path)
  
    # Print help if no files specified
    if not cov.files:
      print 'No covered files found.'
      parser.print_help()
      return 1
  
    # Update tree stats
    cov.UpdateTreeStats()
  
    # Print uninstrumented filenames
    if options.uninstrumented:
      print 'Uninstrumented files:'
      for f in sorted(cov.files):
        covf = cov.files[f]
        if not covf.in_lcov:
          print '  %-6s %-6s %s' % (covf.attrs.get('group'),
                                    covf.attrs.get('language'), f)
  
    # Print tree stats
    if options.tree:
      cov.PrintTree()
  
    # Print stats
    for ps_args in cov.print_stats:
      cov.PrintStat(**ps_args)
  
    # Generate HTML
    if options.html_out:
      html = croc_html.CrocHtml(cov, options.html_out, options.base_url)
      html.Write()
  
    # Normal exit
    return 0
function_tokens: def Main ( argv ) : # Parse args parser = optparse . OptionParser ( ) parser . add_option ( '-i' , '--input' , dest = 'inputs' , type = 'string' , action = 'append' , metavar = 'FILE' , help = 'read LCOV input from FILE' ) parser . add_option ( '-r' , '--root' , dest = 'roots' , type = 'string' , action = 'append' , metavar = 'ROOT[=ALTNAME]' , help = 'add ROOT directory, optionally map in coverage results as ALTNAME' ) parser . add_option ( '-c' , '--config' , dest = 'configs' , type = 'string' , action = 'append' , metavar = 'FILE' , help = 'read settings from configuration FILE' ) parser . add_option ( '-a' , '--addfiles' , dest = 'addfiles' , type = 'string' , action = 'append' , metavar = 'PATH' , help = 'add files from PATH to coverage data' ) parser . add_option ( '-t' , '--tree' , dest = 'tree' , action = 'store_true' , help = 'print tree of code coverage by group' ) parser . add_option ( '-u' , '--uninstrumented' , dest = 'uninstrumented' , action = 'store_true' , help = 'list uninstrumented files' ) parser . add_option ( '-m' , '--html' , dest = 'html_out' , type = 'string' , metavar = 'PATH' , help = 'write HTML output to PATH' ) parser . add_option ( '-b' , '--base_url' , dest = 'base_url' , type = 'string' , metavar = 'URL' , help = 'include URL in base tag of HTML output' ) parser . set_defaults ( inputs = [ ] , roots = [ ] , configs = [ ] , addfiles = [ ] , tree = False , html_out = None , ) options = parser . parse_args ( args = argv ) [ 0 ] cov = Coverage ( ) # Set root directories for coverage for root_opt in options . roots : if '=' in root_opt : cov . AddRoot ( * root_opt . split ( '=' ) ) else : cov . AddRoot ( root_opt ) # Read config files for config_file in options . configs : cov . ParseConfig ( config_file , lcov_queue = options . inputs , addfiles_queue = options . addfiles ) # Parse lcov files for input_filename in options . inputs : cov . ParseLcovFile ( input_filename ) # Add missing files for add_path in options . addfiles : cov . AddFiles ( add_path ) # Print help if no files specified if not cov . files : print 'No covered files found.' parser . print_help ( ) return 1 # Update tree stats cov . UpdateTreeStats ( ) # Print uninstrumented filenames if options . uninstrumented : print 'Uninstrumented files:' for f in sorted ( cov . files ) : covf = cov . files [ f ] if not covf . in_lcov : print '  %-6s %-6s %s' % ( covf . attrs . get ( 'group' ) , covf . attrs . get ( 'language' ) , f ) # Print tree stats if options . tree : cov . PrintTree ( ) # Print stats for ps_args in cov . print_stats : cov . PrintStat ( * * ps_args ) # Generate HTML if options . html_out : html = croc_html . CrocHtml ( cov , options . html_out , options . base_url ) html . Write ( ) # Normal exit return 0