<commit_before># pylint: disable=C0111,R0903

"""Displays battery status, remaining percentage and charging information.

Parameters:
    * battery.device     : Comma-separated list of battery devices to read information from (defaults to auto for auto-detection)
    * battery.warning    : Warning threshold in % of remaining charge (defaults to 20)
    * battery.critical   : Critical threshold in % of remaining charge (defaults to 10)
    * battery.showdevice : If set to "true", add the device name to the widget (defaults to False)
"""

import os
import glob

import bumblebee.input
import bumblebee.output
import bumblebee.engine
import bumblebee.util

try:
    import power
except ImportError:
    pass

class Module(bumblebee.engine.Module):
    def __init__(self, engine, config):
        widgets = []
        super(Module, self).__init__(engine, config, widgets)
        self._batteries = self.parameter("device", "auto").split(",")
        if self._batteries[0] == "auto":
            self._batteries = glob.glob("/sys/class/power_supply/BAT*")
        else:
            self._batteries = [ "/sys/class/power_supply/{}".format(b) for b in self._batteries ]
        if len(self._batteries) == 0:
            self._batteries = [ "/sys/class/power_supply/BAT0" ]
        self.update(widgets)
        engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
            cmd="gnome-power-statistics")

    def update(self, widgets):
        new_widgets = []
        for path in self._batteries:
            widget = self.widget(path)
            if not widget:
                widget = bumblebee.output.Widget(full_text=self.capacity, name=path)
            new_widgets.append(widget)
            self.capacity(widget)
        while len(widgets) > 0: del widgets[0]
        for widget in new_widgets:
            widgets.append(widget)
        self._widgets = widgets

    def remaining(self):
        estimate = 0.0
        try:
            estimate = power.PowerManagement().get_time_remaining_estimate()
            # do not show remaining if on AC
            if estimate == power.common.TIME_REMAINING_UNLIMITED:
                return None
            if estimate == power.common.TIME_REMAINING_UNKNOWN:
                return "n/a"
        except Exception:
            return "n/a"
        return bumblebee.util.durationfmt(estimate*60, shorten=True, suffix=True) # estimate is in minutes<commit_msg>Removed returning n/a<commit_after># pylint: disable=C0111,R0903

"""Displays battery status, remaining percentage and charging information.

Parameters:
    * battery.device     : Comma-separated list of battery devices to read information from (defaults to auto for auto-detection)
    * battery.warning    : Warning threshold in % of remaining charge (defaults to 20)
    * battery.critical   : Critical threshold in % of remaining charge (defaults to 10)
    * battery.showdevice : If set to "true", add the device name to the widget (defaults to False)
"""

import os
import glob

import bumblebee.input
import bumblebee.output
import bumblebee.engine
import bumblebee.util

try:
    import power
except ImportError:
    pass

class Module(bumblebee.engine.Module):
    def __init__(self, engine, config):
        widgets = []
        super(Module, self).__init__(engine, config, widgets)
        self._batteries = self.parameter("device", "auto").split(",")
        if self._batteries[0] == "auto":
            self._batteries = glob.glob("/sys/class/power_supply/BAT*")
        else:
            self._batteries = [ "/sys/class/power_supply/{}".format(b) for b in self._batteries ]
        if len(self._batteries) == 0:
            self._batteries = [ "/sys/class/power_supply/BAT0" ]
        self.update(widgets)
        engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
            cmd="gnome-power-statistics")

    def update(self, widgets):
        new_widgets = []
        for path in self._batteries:
            widget = self.widget(path)
            if not widget:
                widget = bumblebee.output.Widget(full_text=self.capacity, name=path)
            new_widgets.append(widget)
            self.capacity(widget)
        while len(widgets) > 0: del widgets[0]
        for widget in new_widgets:
            widgets.append(widget)
        self._widgets = widgets

    def remaining(self):
        estimate = 0.0
        try:
            estimate = power.PowerManagement().get_time_remaining_estimate()
            # do not show remaining if on AC
            if estimate == power.common.TIME_REMAINING_UNLIMITED:
                return None
            if estimate == power.common.TIME_REMAINING_UNKNOWN:
                return ""
        except Exception:
            return ""
        return bumblebee.util.durationfmt(estimate*60, shorten=True, suffix=True) # estimate is in minutes
{'fraction_non_alphanumeric': 0.097696421225833, 'fraction_numerical': 0.008638420403126285, 'mean_word_length': 2.5496350364963503, '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': '747408', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1369, 'n_words': 361}