def readfile(filename):
    segments = []
    numSegments=0L
    totalBytes=0L
    infile = open(filename, 'r')
    line = infile.readline()
    while line:
        line = line.rstrip()
        fields = line.split(None, 5)
        if 6 == len(fields):
            (memRange, perms, offset, dev, inode, pathname) = fields
        elif 5 == len(fields):
            (memRange, perms, offset, dev, inode) = fields
            pathname = ''
        else:
            raise Exception('cannot unpack %s' % (line,))
        (begin,end) = memRange.split('-')
        t = long(end, 16) - long(begin, 16)
        totalBytes = totalBytes + t
        numSegments = numSegments + 1
        x = (t, memRange, pathname)
        segments.append(x)
        line = infile.readline()
    print filename
    print (numSegments,) % "\tnum segments = %s"
    print "\ttotal bytes = %s (%s)" % (totalBytes, bytesToHumanReadable(totalBytes))
    for i in sorted(segments, key=lambda x: x[0], reverse=True):
        print "\t\t%12s bytes (%s) %33s %s" % (i[0], bytesToHumanReadable(i[0]), i[1], i[2])
dataset/ETHPy150Open Netflix/gcviz/root/apps/apache/htdocs/AdminGCViz/remote-data-collection/parse-proc-pid-maps.py/readfile/swapped operands of `%`