Lichen

tools/showalias.py

1040:c8b0c2d6df5c
5 months ago Paul Boddie Merged changes from the value-replacement branch. value-replacement-for-wrapper
     1 #!/usr/bin/env python2     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_alias_location    16     17 if len(sys.argv) < 3:    18     print >>sys.stderr, "Usage: %s <directory> <alias>" % sys.argv[0]    19     sys.exit(1)    20     21 dirname = sys.argv[1]    22 alias = sys.argv[2]    23     24 filename = join(dirname, "_deduced", "aliases")    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(alias):    35             continue    36     37         first = True    38     39         for column in columns:    40             location = decode_alias_location(column.rstrip(","))    41             path, name, attrnames, version, access_number, invocation = location    42     43             print first and "Alias:" or "Path:", path    44             print "Name:", name    45             print "Attribute names:", attrnames    46             print "Version:", version is None and "{}" or version    47             print "Access number:", access_number is None and "{}" or access_number    48             print "Invocation:", invocation and "true" or "false"    49             print    50     51             first = False    52     53         print "----"    54         print    55     56 finally:    57     f.close()    58     59 # vim: tabstop=4 expandtab shiftwidth=4