blob: 458b637dd50914cef2c7028632690e7534ca669a [file] [log] [blame]
mbligh7c8ea992009-06-22 19:03:08 +00001#!/usr/bin/python -i
mbligh2306f2f2008-11-24 17:12:34 +00002"""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
mblighb22c21f2008-11-27 00:40:38 +000013
mbligh2306f2f2008-11-24 17:12:34 +000014usage = 'usage: %prog [options] scenario_dirpath'
15parser = optparse.OptionParser(usage=usage)
mblighcd84b392008-11-27 00:41:54 +000016parser.add_option("-w", action="store_true", dest="open_for_write")
17
mbligh2306f2f2008-11-24 17:12:34 +000018(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
mblighcd84b392008-11-27 00:41:54 +000029sto = scenario_base.load_parser_result_store(
30 scenario_dirpath, options.open_for_write)
mblighef9e5c32008-12-22 14:52:42 +000031
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