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.
This commit is contained in:
parent
439b140916
commit
5a1addec7f
1 changed files with 6 additions and 5 deletions
|
@ -25,7 +25,7 @@ class Module(core.module.Module):
|
||||||
self.__todos = self.count_items()
|
self.__todos = self.count_items()
|
||||||
core.input.register(
|
core.input.register(
|
||||||
self, button=core.input.LEFT_MOUSE, cmd="{} {}".format(self.__editor, self.__doc)
|
self, button=core.input.LEFT_MOUSE, cmd="{} {}".format(self.__editor, self.__doc)
|
||||||
)
|
)
|
||||||
|
|
||||||
def output(self, widget):
|
def output(self, widget):
|
||||||
return str(self.__todos)
|
return str(self.__todos)
|
||||||
|
@ -40,11 +40,12 @@ class Module(core.module.Module):
|
||||||
|
|
||||||
def count_items(self):
|
def count_items(self):
|
||||||
try:
|
try:
|
||||||
i = -1
|
i = 0
|
||||||
with open(self.__doc) as f:
|
with open(self.__doc) as f:
|
||||||
for i, l in enumerate(f):
|
for l in f.readlines():
|
||||||
pass
|
if l.strip() != '':
|
||||||
return i + 1
|
i += 1
|
||||||
|
return i
|
||||||
except Exception:
|
except Exception:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue