CMS 3D CMS Logo

Classes | Functions | Variables

EdgesToViz Namespace Reference

Classes

class  Col

Functions

def readtable
def runme

Variables

list infile = sys.argv[1]
list lookupfile = sys.argv[3]
list outfile = sys.argv[2]
int use_name = 0

Function Documentation

def EdgesToViz::readtable (   flook)

Definition at line 25 of file EdgesToViz.py.

00026                     :
00027     # field 7 is the library name
00028     tab = {}
00029     next = Col()
00030     cols = {}
00031     for line in flook.xreadlines():
00032         s = line.split()
00033         if not s[7] in cols:
00034             cols[s[7]] = next.next()
00035         s.append(cols[s[7]])
00036         tab[s[0]]=s
00037     return tab,cols
00038         

def EdgesToViz::runme (   infile,
  outfile,
  lookupfile,
  use_name 
)

Definition at line 39 of file EdgesToViz.py.

00040                                              :
00041     fin   = open(infile,'r')
00042     flook = open(lookupfile,'r')
00043     fout  = open(outfile,'w')
00044 
00045     table,libcols = readtable(flook)
00046     
00047     fout.write('digraph prof {')
00048 
00049     uni = {}
00050 #    d=1
00051 #    for i in libcols.items():
00052 #        print >>fout,'lib%d [label="%s",style=filled,color=%s,fontsize=18];' % (d,os.path.basename(i[0].strip('"')),i[1])
00053 #        d += 1
00054         
00055 
00056     for line in fin.xreadlines():
00057         count,from_node,to_node = line.split()
00058         uni[from_node] = 1
00059         uni[to_node] = 1
00060         row_to = table[to_node]
00061         row_from = table[from_node]
00062         
00063         if row_from[-1] == row_to[-1]:
00064             color="\"#000000\""
00065         else:
00066             row=table[to_node]
00067             color=row[-1]
00068             
00069         print >>fout, '%s -> %s [label="%s",fontsize=18,color=%s];' % (from_node,to_node,count,color)
00070 
00071     # print "blob",uni.keys
00072 
00073     for function_id in uni.keys():
00074         function_data = table[function_id]
00075         # print e
00076         node_label = function_data[0]
00077         if use_name: node_label = function_data[-2].strip('"')
00078         leaf_fraction      = float(function_data[5])
00079         recursive_fraction = float(function_data[6])
00080         if recursive_fraction > .03 and recursive_fraction <.20: shape="box"
00081         else: shape="circle"
00082         print >>fout,'%s [label="ID: %s\\nL: %5.1f%%\\nB: %5.1f%%",style=filled,color=%s,shape=%s,fontsize=18];' % (node_label,node_label,leaf_fraction*100, recursive_fraction*100,function_data[-1],shape)
00083 
00084     fout.write('}')


Variable Documentation

list EdgesToViz::infile = sys.argv[1]
list EdgesToViz::lookupfile = sys.argv[3]

Definition at line 92 of file EdgesToViz.py.

list EdgesToViz::outfile = sys.argv[2]

Definition at line 93 of file EdgesToViz.py.