Back to index

python3.2  3.2.2
Functions
combinerefs Namespace Reference

Functions

def read
def combine

Function Documentation

def combinerefs.combine (   fname)

Definition at line 88 of file combinerefs.py.

00088 
00089 def combine(fname):
00090     f = open(fname)
00091 
00092     fi = iter(f)
00093 
00094     for line in read(fi, re.compile(r'^Remaining objects:$'), False):
00095         pass
00096 
00097     crack = re.compile(r'([a-zA-Z\d]+) \[(\d+)\] (.*)')
00098     addr2rc = {}
00099     addr2guts = {}
00100     before = 0
00101     for line in read(fi, re.compile(r'^Remaining object addresses:$'), False):
00102         m = crack.match(line)
00103         if m:
00104             addr, addr2rc[addr], addr2guts[addr] = m.groups()
00105             before += 1
00106         else:
00107             print('??? skipped:', line)
00108 
00109     after = 0
00110     for line in read(fi, crack, True):
00111         after += 1
00112         m = crack.match(line)
00113         assert m
00114         addr, rc, guts = m.groups() # guts is type name here
00115         if addr not in addr2rc:
00116             print('??? new object created while tearing down:', line.rstrip())
00117             continue
00118         print(addr, end=' ')
00119         if rc == addr2rc[addr]:
00120             print('[%s]' % rc, end=' ')
00121         else:
00122             print('[%s->%s]' % (addr2rc[addr], rc), end=' ')
00123         print(guts, addr2guts[addr])
00124 
00125     f.close()
00126     print("%d objects before, %d after" % (before, after))

Here is the call graph for this function:

Here is the caller graph for this function:

def combinerefs.read (   fileiter,
  pat,
  whilematch 
)

Definition at line 81 of file combinerefs.py.

00081 
00082 def read(fileiter, pat, whilematch):
00083     for line in fileiter:
00084         if bool(pat.match(line)) == whilematch:
00085             yield line
00086         else:
00087             break

Here is the caller graph for this function: