From 5a1addec7f26e0eac294842a91cc4125f9520e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Soykan=20Ert=C3=BCrk?= Date: Sat, 14 Aug 2021 20:14:54 +0300 Subject: [PATCH 1/2] Fixing a small bug on todo module todo counts new lines (blank lines) as todo and increments todo count. After my fix todo doesn't counts blank lines. --- bumblebee_status/modules/contrib/todo.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bumblebee_status/modules/contrib/todo.py b/bumblebee_status/modules/contrib/todo.py index df2d788..6c69f10 100644 --- a/bumblebee_status/modules/contrib/todo.py +++ b/bumblebee_status/modules/contrib/todo.py @@ -25,7 +25,7 @@ class Module(core.module.Module): self.__todos = self.count_items() core.input.register( self, button=core.input.LEFT_MOUSE, cmd="{} {}".format(self.__editor, self.__doc) - ) + ) def output(self, widget): return str(self.__todos) @@ -40,11 +40,12 @@ class Module(core.module.Module): def count_items(self): try: - i = -1 + i = 0 with open(self.__doc) as f: - for i, l in enumerate(f): - pass - return i + 1 + for l in f.readlines(): + if l.strip() != '': + i += 1 + return i except Exception: return 0 From 05f76c0d9a236426f6e99a48c6b685f375395280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Soykan=20Ert=C3=BCrk?= Date: Sat, 14 Aug 2021 20:16:45 +0300 Subject: [PATCH 2/2] Update todo.py --- bumblebee_status/modules/contrib/todo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bumblebee_status/modules/contrib/todo.py b/bumblebee_status/modules/contrib/todo.py index 6c69f10..76e289e 100644 --- a/bumblebee_status/modules/contrib/todo.py +++ b/bumblebee_status/modules/contrib/todo.py @@ -25,7 +25,7 @@ class Module(core.module.Module): self.__todos = self.count_items() core.input.register( self, button=core.input.LEFT_MOUSE, cmd="{} {}".format(self.__editor, self.__doc) - ) + ) def output(self, widget): return str(self.__todos)