1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tools/showalias.py Mon Jun 25 14:27:00 2018 +0200
1.3 @@ -0,0 +1,53 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +from os.path import abspath, split
1.7 +import sys
1.8 +
1.9 +# Find the modules.
1.10 +
1.11 +try:
1.12 + import encoders
1.13 +except ImportError:
1.14 + parent = abspath(split(split(__file__)[0])[0])
1.15 + if split(parent)[1] == "Lichen":
1.16 + sys.path.append(parent)
1.17 +
1.18 +from encoders import decode_alias_location
1.19 +
1.20 +if len(sys.argv) < 3:
1.21 + print >>sys.stderr, "Usage: %s <filename> <alias>" % sys.argv[0]
1.22 + sys.exit(1)
1.23 +
1.24 +filename = sys.argv[1]
1.25 +alias = sys.argv[2]
1.26 +
1.27 +f = open(filename)
1.28 +try:
1.29 + for line in f.xreadlines():
1.30 + columns = line.rstrip().split(" ")
1.31 + if not columns[0].startswith(alias):
1.32 + continue
1.33 +
1.34 + first = True
1.35 +
1.36 + for column in columns:
1.37 + location = decode_alias_location(column.rstrip(","))
1.38 + path, name, attrnames, version, access_number, invocation = location
1.39 +
1.40 + print first and "Alias:" or "Path:", path
1.41 + print "Name:", name
1.42 + print "Attribute names:", attrnames
1.43 + print "Version:", version is None and "{}" or version
1.44 + print "Access number:", access_number is None and "{}" or access_number
1.45 + print "Invocation:", invocation and "true" or "false"
1.46 + print
1.47 +
1.48 + first = False
1.49 +
1.50 + print "----"
1.51 + print
1.52 +
1.53 +finally:
1.54 + f.close()
1.55 +
1.56 +# vim: tabstop=4 expandtab shiftwidth=4