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