Lichen

tools/showplan.py

913:85cb541354aa
12 months ago Paul Boddie Silence warnings about incomplete string copying despite zero-initialised memory being used.
     1 #!/usr/bin/env python     2      3 from os.path import abspath, exists, join, split     4 import sys     5      6 # Find the modules.     7      8 try:     9     import encoders    10 except ImportError:    11     parent = abspath(split(split(__file__)[0])[0])    12     if split(parent)[1] == "Lichen":    13         sys.path.append(parent)    14     15 from encoders import decode_access_location    16     17 if len(sys.argv) < 3:    18     print >>sys.stderr, "Usage: %s <directory> <access>" % sys.argv[0]    19     sys.exit(1)    20     21 dirname = sys.argv[1]    22 access = sys.argv[2]    23     24 filename = join(dirname, "_deduced", "attribute_plans")    25     26 if not exists(filename):    27     print >>sys.stderr, "Directory %s does not provide file %s." % (dirname, filename)    28     sys.exit(1)    29     30 f = open(filename)    31 try:    32     for line in f.xreadlines():    33         columns = line.rstrip().split()    34         if not columns[0].startswith(access):    35             continue    36     37         location, name, test, test_type, base, traversed, traversal_modes, \    38         traversal_attrnames, context, context_test, \    39         first_method, final_method, attr, accessor_kinds = columns    40     41         path, _name, attrnames, access_number = decode_access_location(location)    42     43         print "Location:", location    44         print "Name:", name    45         print "Attribute names:", attrnames    46         print "Access number:", access_number    47         print "Test:", test    48         print "Test type:", test_type    49         print "Base:", base    50         print "Traversed:", traversed    51         print "Traversal modes:", traversal_modes    52         print "Traversed attributes:", traversal_attrnames    53         print "Context:", context    54         print "Context test:", context_test    55         print "First method:", first_method    56         print "Final method:", final_method    57         print "Origin/attribute:", attr    58         print "Accessor kinds:", accessor_kinds    59         print    60     61 finally:    62     f.close()    63     64 # vim: tabstop=4 expandtab shiftwidth=4