# HG changeset patch # User Paul Boddie # Date 1529929620 -7200 # Node ID e9780223ee2f5c82c7377400b8b7f8cd124d9c7d # Parent ed201ad4d8e1cf534ccb45e959fff38da99b7f07 Added some tools to present computed information more accessibly. diff -r ed201ad4d8e1 -r e9780223ee2f encoders.py --- a/encoders.py Sun Jun 24 18:47:03 2018 +0200 +++ b/encoders.py Mon Jun 25 14:27:00 2018 +0200 @@ -3,7 +3,7 @@ """ Encoder functions, producing representations of program objects. -Copyright (C) 2016, 2017 Paul Boddie +Copyright (C) 2016, 2017, 2018 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -87,6 +87,26 @@ t.access_number is not None and ":#%d" % t.access_number or "", invocation and "!" or "") +def decode_alias_location(s): + + "Decode the alias location 's'." + + path, name, rest = s.split(":", 2) + attrnames = version = access_number = None + invocation = rest.endswith("!") + + t = rest.rstrip("!").split(":#") + if len(t) > 1: + rest = t[0]; access_number = int(t[1]) + + t = rest.split(":=") + if len(t) > 1: + attrnames = t[0]; version = int(t[1]) + else: + attrnames = rest + + return path, name, attrnames, version, access_number, invocation + def encode_location(t): "Encode the general location 't' in a concise form." diff -r ed201ad4d8e1 -r e9780223ee2f tools/showalias.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/showalias.py Mon Jun 25 14:27:00 2018 +0200 @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +from os.path import abspath, split +import sys + +# Find the modules. + +try: + import encoders +except ImportError: + parent = abspath(split(split(__file__)[0])[0]) + if split(parent)[1] == "Lichen": + sys.path.append(parent) + +from encoders import decode_alias_location + +if len(sys.argv) < 3: + print >>sys.stderr, "Usage: %s " % sys.argv[0] + sys.exit(1) + +filename = sys.argv[1] +alias = sys.argv[2] + +f = open(filename) +try: + for line in f.xreadlines(): + columns = line.rstrip().split(" ") + if not columns[0].startswith(alias): + continue + + first = True + + for column in columns: + location = decode_alias_location(column.rstrip(",")) + path, name, attrnames, version, access_number, invocation = location + + print first and "Alias:" or "Path:", path + print "Name:", name + print "Attribute names:", attrnames + print "Version:", version is None and "{}" or version + print "Access number:", access_number is None and "{}" or access_number + print "Invocation:", invocation and "true" or "false" + print + + first = False + + print "----" + print + +finally: + f.close() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r ed201ad4d8e1 -r e9780223ee2f tools/showplan.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/showplan.py Mon Jun 25 14:27:00 2018 +0200 @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +import sys + +if len(sys.argv) < 3: + print >>sys.stderr, "Usage: %s " % sys.argv[0] + sys.exit(1) + +filename = sys.argv[1] +access = sys.argv[2] + +f = open(filename) +try: + for line in f.xreadlines(): + columns = line.rstrip().split() + if not columns[0].startswith(access): + continue + + location, name, test, test_type, base, traversed, traversal_modes, \ + attrnames, context, context_test, first_method, final_method, attr, \ + accessor_kinds = columns + + print "Location:", location + print "Name:", name + print "Test:", test + print "Test type:", test_type + print "Base:", base + print "Traversed:", traversed + print "Traversal modes:", traversal_modes + print "Attribute names:", attrnames + print "Context:", context + print "Context test:", context_test + print "First method:", first_method + print "Final method:", final_method + print "Origin/attribute:", attr + print "Accessor kinds:", accessor_kinds + print + +finally: + f.close() + +# vim: tabstop=4 expandtab shiftwidth=4