mbligh | 7c8ea99 | 2009-06-22 19:03:08 +0000 | [diff] [blame^] | 1 | #!/usr/bin/python -i |
mbligh | 2306f2f | 2008-11-24 17:12:34 +0000 | [diff] [blame] | 2 | """Inspector for parser_result.store from specified scenerio package. |
| 3 | |
| 4 | Load in parser_result.store as 'sto' and launch interactive interp. |
| 5 | Define some helper functions as required. |
| 6 | """ |
| 7 | |
| 8 | import optparse, os, sys |
| 9 | from os import path |
| 10 | import common |
| 11 | from autotest_lib.tko.parsers.test import scenario_base |
| 12 | |
mbligh | b22c21f | 2008-11-27 00:40:38 +0000 | [diff] [blame] | 13 | |
mbligh | 2306f2f | 2008-11-24 17:12:34 +0000 | [diff] [blame] | 14 | usage = 'usage: %prog [options] scenario_dirpath' |
| 15 | parser = optparse.OptionParser(usage=usage) |
mbligh | cd84b39 | 2008-11-27 00:41:54 +0000 | [diff] [blame] | 16 | parser.add_option("-w", action="store_true", dest="open_for_write") |
| 17 | |
mbligh | 2306f2f | 2008-11-24 17:12:34 +0000 | [diff] [blame] | 18 | (options, args) = parser.parse_args() |
| 19 | if len(args) < 1: |
| 20 | parser.print_help() |
| 21 | sys.exit(1) |
| 22 | |
| 23 | scenario_dirpath = path.normpath(args[0]) |
| 24 | if 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 | |
mbligh | cd84b39 | 2008-11-27 00:41:54 +0000 | [diff] [blame] | 29 | sto = scenario_base.load_parser_result_store( |
| 30 | scenario_dirpath, options.open_for_write) |
mbligh | ef9e5c3 | 2008-12-22 14:52:42 +0000 | [diff] [blame] | 31 | |
| 32 | |
| 33 | def 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 |