<commit_before># -*- coding: UTF-8 -*-

# smart function inspired by py-SMART https://github.com/freenas/py-SMART
# under Copyright (C) 2015 <NAME> and GPL2

"""Displays HDD smart status of different drives or all drives

Parameters:
    * smartstatus.display: how to display (defaults to 'combined', other choices: 'seperate' or 'singles')
    * smartstauts.drives: in the case of singles which drives to display, separated comma list value, multiple accepted (defaults to 'sda', example:'sda,sdc')
"""

import os

import shutil

import core.module
import core.widget
import core.decorators

import util.cli

class Module(core.module.Module):
    @core.decorators.every(minutes=5)
    def __init__(self, config, theme):
        super().__init__(config, theme, [])

        self.devices = self.list_devices()
        self.display = self.parameter('display', 'combined')
        self.drives = self.parameter('drives', 'sda')
        self.widgets(self.create_widgets())

    def create_widgets(self):
        widgets = []
        if self.display == 'combined':
            widget = core.widget.Widget()
            widget.set('device', 'combined')
            widget.set('assessment', self.combined())
            self.output(widget)
            widgets.append(widget)
        else:
            for device in self.devices:
                if self.display == 'singles' and device not in self.drives:
                    continue
                widget = core.widget.Widget()
                widget.set('device', device)
                widget.set('assessment', self.smart(device))
                self.output(widget)
                widgets.append(widget)
        return widgets

    def update(self):
        for widget in self.widgets():
            device = widget.get('device')
            if device == 'combined':
                widget.set('assessment', self.combined())
                self.output(widget)<commit_msg>[modules/smartstatus] Add module reference to widgets<commit_after># -*- coding: UTF-8 -*-

# smart function inspired by py-SMART https://github.com/freenas/py-SMART
# under Copyright (C) 2015 <NAME> and GPL2

"""Displays HDD smart status of different drives or all drives

Parameters:
    * smartstatus.display: how to display (defaults to 'combined', other choices: 'seperate' or 'singles')
    * smartstauts.drives: in the case of singles which drives to display, separated comma list value, multiple accepted (defaults to 'sda', example:'sda,sdc')
"""

import os

import shutil

import core.module
import core.widget
import core.decorators

import util.cli

class Module(core.module.Module):
    @core.decorators.every(minutes=5)
    def __init__(self, config, theme):
        super().__init__(config, theme, [])

        self.devices = self.list_devices()
        self.display = self.parameter('display', 'combined')
        self.drives = self.parameter('drives', 'sda')
        self.widgets(self.create_widgets())

    def create_widgets(self):
        widgets = []
        if self.display == 'combined':
            widget = core.widget.Widget(module=self)
            widget.set('device', 'combined')
            widget.set('assessment', self.combined())
            self.output(widget)
            widgets.append(widget)
        else:
            for device in self.devices:
                if self.display == 'singles' and device not in self.drives:
                    continue
                widget = core.widget.Widget(module=self)
                widget.set('device', device)
                widget.set('assessment', self.smart(device))
                self.output(widget)
                widgets.append(widget)
        return widgets

    def update(self):
        for widget in self.widgets():
            device = widget.get('device')
            if device == 'combined':
                widget.set('assessment', self.combined())
                self.output(widget)
{'fraction_non_alphanumeric': 0.1170594262295082, 'fraction_numerical': 0.003586065573770492, 'mean_word_length': 2.3927019982623805, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '7295566', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1047, 'n_words': 286}