def calculate_total_active(self):
        """ Read proc.txt file and calculate 'self.active' and 'self.total' """
        all_cores = set(xrange(self.cores))
        self.total = [[] for _ in all_cores]
        self.active = [[] for _ in all_cores]
        with open(self.infile, "r") as fh:
            # parsing logic:
            # - keep spinning through lines until see the cpu summary line
            #   (taken to indicate start of new record).
            # - extract values for individual cores after the summary line,
            #   keeping  track of seen cores until no more lines match 'cpu\d+'
            #   pattern.
            # - For every core not seen in this record, pad zeros.
            # - Loop
            try:
                while True:
                    line = fh.next()
                    if not line.startswith('cpu '):
                        continue

                    seen_cores = set([])
                    line = fh.next()
                    match = self.cpuid_regex.match(line)
                    while match:
                        cpu_id = int(match.group(1))
                        seen_cores.add(cpu_id)
                        times = map(int, line.split()[1:])  # first column is the cpu_id
                        self.total[cpu_id].append(sum(times))
                        self.active[cpu_id].append(sum(times) - times[self.idle_time_index])
                        line = fh.next()
                        match = self.cpuid_regex.match(line)

                    for unseen_core in all_cores - seen_cores:
                        self.total[unseen_core].append(0)
                        self.active[unseen_core].append(0)
            except __HOLE__:  # EOF
                pass
dataset/ETHPy150Open ARM-software/workload-automation/wlauto/instrumentation/coreutil/__init__.py/Calculator.calculate_total_active