def read_cinfo(cinfo_file, now):
    ' Try to extract useful info from the cinfo file '
    result = {'naccesses': 0, 'last_access': 0, 'by_hour': {'01': 0, '12': 0, '24': 0}, 'bytes_hr': {'01': 0, '12': 0, '24': 0}}
    cf = open(cinfo_file, 'rb')
    buf = cf.read(_header_fmt_size)
    if (len(buf) < _header_fmt_size):
        raise ReadCInfoError(('%s header too short' % cinfo_file), result)
    (version, buffer_size, file_size) = struct.unpack(_header_fmt, buf)
    if (version != 2):
        raise ReadCInfoError(('%s unknown version: %s' % (cinfo_file, version)), result)
    buff_synced_len = int(math.ceil(((float(file_size) / buffer_size) / 8)))
    if (file_size == 0):
        buff_synced_len = 1
    cf.read(buff_synced_len)
    cf.read((16 + 8))
    buf = cf.read(_int_fmt_size)
    if (len(buf) < _int_fmt_size):
        raise ReadCInfoError(('%s: invalid access field' % cinfo_file), result)
    (access_count,) = struct.unpack(_int_fmt, buf)
    result['naccesses'] = access_count
    if (access_count < 0):
        raise ReadCInfoError(('%s: invalid access count: %s' % (cinfo_file, access_count)), result)
    elif (access_count == 0):
        return result
    hr_01 = (now - (60 * 60))
    hr_12 = (now - ((12 * 60) * 60))
    hr_24 = (now - ((24 * 60) * 60))
    try:
        for buf in iter((lambda : cf.read(_status_fmt_size)), b''):
            (access_time, _, bytes_disk, bytes_ram, _) = struct.unpack(_status_fmt, buf)
            result['last_access'] = access_time
            intervals = list()
            if (access_time >= hr_01):
                intervals.append('01')
            if (access_time >= hr_12):
                intervals.append('12')
            if (access_time >= hr_24):
                intervals.append('24')
            else:
                next
            for interval in intervals:
                result['by_hour'][interval] += 1
                result['bytes_hr'][interval] += (bytes_disk + bytes_ram)
    except struct.error as ex:
        raise ReadCInfoError(('%s unable to decode access time data: %s' % (cinfo_file, str(ex))), result)
    return result
Try to extract useful info from the cinfo file
def read_cinfo(cinfo_file, now):
    '  '
    result = {'naccesses': 0, 'last_access': 0, 'by_hour': {'01': 0, '12': 0, '24': 0}, 'bytes_hr': {'01': 0, '12': 0, '24': 0}}
    cf = open(cinfo_file, 'rb')
    buf = cf.read(_header_fmt_size)
    if (len(buf) < _header_fmt_size):
        raise ReadCInfoError(('%s header too short' % cinfo_file), result)
    (version, buffer_size, file_size) = struct.unpack(_header_fmt, buf)
    if (version != 2):
        raise ReadCInfoError(('%s unknown version: %s' % (cinfo_file, version)), result)
    buff_synced_len = int(math.ceil(((float(file_size) / buffer_size) / 8)))
    if (file_size == 0):
        buff_synced_len = 1
    cf.read(buff_synced_len)
    cf.read((16 + 8))
    buf = cf.read(_int_fmt_size)
    if (len(buf) < _int_fmt_size):
        raise ReadCInfoError(('%s: invalid access field' % cinfo_file), result)
    (access_count,) = struct.unpack(_int_fmt, buf)
    result['naccesses'] = access_count
    if (access_count < 0):
        raise ReadCInfoError(('%s: invalid access count: %s' % (cinfo_file, access_count)), result)
    elif (access_count == 0):
        return result
    hr_01 = (now - (60 * 60))
    hr_12 = (now - ((12 * 60) * 60))
    hr_24 = (now - ((24 * 60) * 60))
    try:
        for buf in iter((lambda : cf.read(_status_fmt_size)), b):
            (access_time, _, bytes_disk, bytes_ram, _) = struct.unpack(_status_fmt, buf)
            result['last_access'] = access_time
            intervals = list()
            if (access_time >= hr_01):
                intervals.append('01')
            if (access_time >= hr_12):
                intervals.append('12')
            if (access_time >= hr_24):
                intervals.append('24')
            else:
                next
            for interval in intervals:
                result['by_hour'][interval] += 1
                result['bytes_hr'][interval] += (bytes_disk + bytes_ram)
    except struct.error as ex:
        raise ReadCInfoError(('%s unable to decode access time data: %s' % (cinfo_file, str(ex))), result)
    return result