<commit_before>from .base import PluginBase


class MemoryPlugin(PluginBase):

    def configure(self, config):
        if 'divisor' not in config:
            config['divisor'] = 1024.0**2
        if 'format' not in config:
            config['format'] = "{used}/{total} {percent}%%"
        config['format'] = self.fix_format(config['format'])
        return config

    def get_meminfo(self):

        div = float(self.config['divisor'])
        mem_dict = {}
        lines = self.read_file('/proc/meminfo')
        for line in lines.split("\n"):
            data = [info for info in line.split(" ") if info]
            if len(data) > 0:
                mem_dict[data[0].replace(":", "")] = int(data[1])

        mem_info = {
            'used': '%.2f' % ((mem_dict['Active'])/div),
            'total': '%.2f' % (mem_dict['MemTotal']/div),
            'free': '%.2f' % (mem_dict['MemFree']/div),
        }

        percent_used = int((mem_dict['Active']/mem_dict['MemTotal']) * 100)
        mem_info['percent'] = percent_used<commit_msg>memory.py: subtracted buffers and cached from used memory total<commit_after>from .base import PluginBase


class MemoryPlugin(PluginBase):

    def configure(self, config):
        if 'divisor' not in config:
            config['divisor'] = 1024.0**2
        if 'format' not in config:
            config['format'] = "{used}/{total} {percent}%%"
        config['format'] = self.fix_format(config['format'])
        return config

    def get_meminfo(self):

        div = float(self.config['divisor'])
        mem_dict = {}
        lines = self.read_file('/proc/meminfo')
        for line in lines.split("\n"):
            data = [info for info in line.split(" ") if info]
            if len(data) > 0:
                mem_dict[data[0].replace(":", "")] = int(data[1])

        free_mem = mem_dict['MemFree']
        free_mem += mem_dict['Buffers'] 
        free_mem += mem_dict['Cached']

        used_mem = mem_dict['MemTotal'] - free_mem

        mem_info = {
            'used': '%.2f' % (used_mem/div),
            'total': '%.2f' % (mem_dict['MemTotal']/div),
            'free': '%.2f' % (free_mem/div),
        }

        percent_used = int((used_mem/mem_dict['MemTotal']) * 100)
        mem_info['percent'] = percent_used
{'fraction_non_alphanumeric': 0.16761988561372634, 'fraction_numerical': 0.013198416190057193, 'mean_word_length': 2.276657060518732, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4356151', 'n_tokens_mistral': 745, 'n_tokens_neox': 705, 'n_words': 150}