<commit_before># pylint: disable=C0111,R0903

"""Displays the number of todo items from a text file

Parameters:
    * todo.file: File to read TODOs from (defaults to ~/Documents/todo.txt)
"""

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


class Module(bumblebee.engine.Module):


    def __init__(self, engine, config):
        super(Module, self).__init__(engine, config,
            bumblebee.output.Widget(full_text=self.output)
        )
        self._todos = self.count_items()


    def output(self, widget):
       self._todos = self.count_items()
       return str(self._todos)


    def state(self, widgets):
        if self._todos == 0:
            return "empty"
        return "items"


    def count_items(filename):
        try:
            i = -1
            doc = self.parameter("file", "~/Documents/todo.txt")
            with open(doc) as f:
                for i, l in enumerate(f):
                    pass
            return i+1
        except Exception:
            return 0

# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4<commit_msg>fix todo module path expansion<commit_after># pylint: disable=C0111,R0903

"""Displays the number of todo items from a text file

Parameters:
    * todo.file: File to read TODOs from (defaults to ~/Documents/todo.txt)
"""

import bumblebee.input
import bumblebee.output
import bumblebee.engine
import os.path


class Module(bumblebee.engine.Module):


    def __init__(self, engine, config):
        super(Module, self).__init__(engine, config,
            bumblebee.output.Widget(full_text=self.output)
        )
        self._doc = os.path.expanduser(self.parameter("file", "~/Documents/todo.txt"))
        self._todos = self.count_items()


    def output(self, widget):
       self._todos = self.count_items()
       return str(self._todos)


    def state(self, widgets):
        if self._todos == 0:
            return "empty"
        return "items"


    def count_items(self):
        try:
            i = -1
            with open(self._doc) as f:
                for i, l in enumerate(f):
                    pass
            return i+1
        except Exception:
            return 0
{'fraction_non_alphanumeric': 0.10352725606962895, 'fraction_numerical': 0.012368300503893724, 'mean_word_length': 2.1790393013100435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3068394', 'n_tokens_mistral': 702, 'n_tokens_neox': 655, 'n_words': 174}