<commit_before>from os import getenv, system
from time import sleep
from copy import deepcopy


class InterruptDiff(object):

    def __init__(self):
        self.filename = '/proc/interrupts'
        self.previous = []
        self.current = []
        self.interval = int(getenv('INTERVAL', 1))
        self.diff = []
        self.iterations = int(getenv('ITERATIONS', 60))
        self.skipzero = bool(getenv('SKIPZERO', True))
        self.ignore_limit = int(getenv('IGNORE_LE', 80))

    def parse(self):
        with open(self.filename) as file_fd:
            return [line.strip().split() for line in file_fd.readlines()]

    def eval(self):
        self.diff = deepcopy(self.current)
        changes = []
        for ln, line in enumerate(self.diff):
            changed = False
            for cn, column in enumerate(line):
                if not column.isdigit():
                    continue
                new_value = int(column) - int(self.previous[ln][cn])
                if new_value > 0:
                    changed = True
                self.diff[ln][cn] = str(new_value)

            changes.append(changed)

    def __print__(self):
        def is_changed(line):
            return any(int(x) > self.ignore_limit for x in line if x.isdigit())
        system('clear')
        print
        cpucount = len(self.diff[0]) - 1
        total = ['Total:'] + [sum(int(x[column]) for x in self.diff if len(x)
                                  > cpucount + 1) for column in xrange(1, cpucount + 2)]
        print "\t".join(str(x) for x in total)

        for line in self.diff:
            if line[0] == 'CPU0':
                line.insert(0, ' ')
            elif self.skipzero and not is_changed(line):
                continue
            print "\t".join(line)

    def run(self):
        while self.iterations > -1:
            self.iterations -= 1
            sleep(self.interval)
            self.previous = self.current
            self.current = self.parse()
            if not all((self.previous, self.current)):
                continue
            self.eval()
            self.__print__()
<commit_msg>Refactoring: deleted useless code in diff eval in irqtop.<commit_after>from os import getenv, system
from time import sleep
from copy import deepcopy


class InterruptDiff(object):

    def __init__(self):
        self.filename = '/proc/interrupts'
        self.previous = []
        self.current = []
        self.interval = int(getenv('INTERVAL', 1))
        self.diff = []
        self.iterations = int(getenv('ITERATIONS', 60))
        self.skipzero = bool(getenv('SKIPZERO', True))
        self.ignore_limit = int(getenv('IGNORE_LE', 80))

    def parse(self):
        with open(self.filename) as file_fd:
            return [line.strip().split() for line in file_fd.readlines()]

    def eval(self):
        self.diff = deepcopy(self.current)
        for ln, line in enumerate(self.diff):
            for cn, column in enumerate(line):
                if not column.isdigit():
                    continue
                new_value = int(column) - int(self.previous[ln][cn])
                self.diff[ln][cn] = str(new_value)

    def __print__(self):
        def is_changed(line):
            return any(int(x) > self.ignore_limit for x in line if x.isdigit())
        system('clear')
        print
        cpucount = len(self.diff[0]) - 1
        total = ['Total:'] + [sum(int(x[column]) for x in self.diff if len(x)
                                  > cpucount + 1) for column in xrange(1, cpucount + 2)]
        print "\t".join(str(x) for x in total)

        for line in self.diff:
            if line[0] == 'CPU0':
                line.insert(0, ' ')
            elif self.skipzero and not is_changed(line):
                continue
            print "\t".join(line)

    def run(self):
        while self.iterations > -1:
            self.iterations -= 1
            sleep(self.interval)
            self.previous = self.current
            self.current = self.parse()
            if not all((self.previous, self.current)):
                continue
            self.eval()
            self.__print__()

{'fraction_non_alphanumeric': 0.1188118811881188, 'fraction_numerical': 0.007486114465105047, 'mean_word_length': 1.746684350132626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5968879', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1177, 'n_words': 307}