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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/usr/bin/env python
import cPickle as pickle
import sys
from datasheet_tables import load_datasheet_pages, \
abs_tables_from_pages, \
profile_factory
# register profiles:
import smrbase
import imch_conf
import gbe
def print_stuff(a_t, options):
for t in a_t.tables:
if options.warning_only and t.check_ranges():
continue
print '============================================================'
print '%xh' % t.offset, t.reg_name
for h, fmt in t.HeaderAttr:
print " %-15s %s" % (h, fmt(t, getattr(t, h)))
print
for l in t.lines:
print " ----------------"
l.simple_print()
print
print
def main():
from optparse import OptionParser
parser = OptionParser(usage="usage: %prog [options] <tables_group> datasheet.xml")
parser.add_option("-p", "--pickle", dest="pickle_filename",
help="save parsed data to PICKLE", metavar="PICKLE")
parser.add_option("-W", "--Warning-only", action="store_true",
dest="warning_only", default=False,
help="only display tables for which a problem "
"has been detected")
(options, args) = parser.parse_args()
if len(args) < 1:
parser.print_help()
return 1
try:
datasheet = args[1]
except IndexError:
datasheet = "/home/xilun/hard/cooked/datasheet_320066.xml"
tables_group = args[0]
profile = profile_factory(tables_group)
pages = load_datasheet_pages(datasheet, profile.min_page, profile.max_page)
a_t = abs_tables_from_pages(pages, profile)
print_stuff(a_t, options)
if options.pickle_filename:
f = open(options.pickle_filename, "wb")
pickle.dump(a_t, f, -1)
f.close()
sys.exit(main())
|