• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python -i
2"""Inspector for parser_result.store from specified scenerio package.
3
4Load in parser_result.store as 'sto' and launch interactive interp.
5Define some helper functions as required.
6"""
7
8import optparse, os, sys
9from os import path
10import common
11from autotest_lib.tko.parsers.test import scenario_base
12
13
14usage = 'usage: %prog [options] scenario_dirpath'
15parser = optparse.OptionParser(usage=usage)
16parser.add_option("-w", action="store_true", dest="open_for_write")
17
18(options, args) = parser.parse_args()
19if len(args) < 1:
20    parser.print_help()
21    sys.exit(1)
22
23scenario_dirpath = path.normpath(args[0])
24if not path.exists(scenario_dirpath) or not path.isdir(scenario_dirpath):
25    print 'Invalid scenarios_dirpath:', scenario_dirpath
26    parser.print_help()
27    sys.exit(1)
28
29sto = scenario_base.load_parser_result_store(
30    scenario_dirpath, options.open_for_write)
31
32
33def compare(left_tag, right_tag):
34    missing = set([left_tag, right_tag]).difference(sto.keys())
35    if missing:
36        print 'Store does not have the following tag(s): ', ','.join(missing)
37        print 'Doing nothing.'
38        return
39
40    for diffline in scenario_base.compare_parser_results(
41        sto[left_tag], sto[right_tag]):
42        print diffline
43