fixed empty todo management
parent
f93e5b7f70
commit
852a0e05db
53
silojourn.py
53
silojourn.py
|
@ -223,7 +223,11 @@ class Journaler():
|
||||||
# open self.config.tracker file
|
# open self.config.tracker file
|
||||||
# iterate through lines
|
# iterate through lines
|
||||||
# find line that begins with hash
|
# find line that begins with hash
|
||||||
with open( self.config.tracker, 'w+' ) as tracker_file:
|
if not os.path.exists( self.config.tracker ):
|
||||||
|
f = open(self.config.tracker, 'w+')
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
with open( self.config.tracker, 'r' ) as tracker_file:
|
||||||
for line in tracker_file:
|
for line in tracker_file:
|
||||||
m = re.search( "^{0}\t.*$".format( task.hash ), line )
|
m = re.search( "^{0}\t.*$".format( task.hash ), line )
|
||||||
print(line)
|
print(line)
|
||||||
|
@ -253,30 +257,35 @@ class Journaler():
|
||||||
( todo.hash, "({0}) {1}".format(todo.topic, todo.text) , False )
|
( todo.hash, "({0}) {1}".format(todo.topic, todo.text) , False )
|
||||||
)
|
)
|
||||||
|
|
||||||
code, hashes_marked_complete = self.d.checklist(
|
|
||||||
text="TODO Entries",
|
|
||||||
choices=choices,
|
|
||||||
backtitle="Select tasks to complete.",
|
|
||||||
width=self.d.maxsize()[1],
|
|
||||||
cancel_label="Exit",
|
|
||||||
ok_label="Complete"
|
|
||||||
)
|
|
||||||
|
|
||||||
if code == self.d.OK:
|
if len(choices) > 0:
|
||||||
# it only returns the hashes
|
code, hashes_marked_complete = self.d.checklist(
|
||||||
# we want to create a new list of tasks for tasks that should be completed
|
text="TODO Entries",
|
||||||
tasks_to_complete = list()
|
choices=choices,
|
||||||
|
backtitle="Select tasks to complete.",
|
||||||
|
width=self.d.maxsize()[1],
|
||||||
|
cancel_label="Exit",
|
||||||
|
ok_label="Complete"
|
||||||
|
)
|
||||||
|
|
||||||
# iterate through all tasks so nothing gets missed
|
if code == self.d.OK:
|
||||||
for todo in self._get_todos():
|
# it only returns the hashes
|
||||||
# in each iteration we want to iterate through the hashes marked complete and add tasks
|
# we want to create a new list of tasks for tasks that should be completed
|
||||||
# with a matching hash to that new list
|
tasks_to_complete = list()
|
||||||
for item in hashes_marked_complete:
|
|
||||||
if todo.hash == item:
|
|
||||||
tasks_to_complete.append(todo)
|
|
||||||
|
|
||||||
for selection in tasks_to_complete:
|
# iterate through all tasks so nothing gets missed
|
||||||
self._mark_task_complete( selection )
|
for todo in self._get_todos():
|
||||||
|
# in each iteration we want to iterate through the hashes marked complete and add tasks
|
||||||
|
# with a matching hash to that new list
|
||||||
|
for item in hashes_marked_complete:
|
||||||
|
if todo.hash == item:
|
||||||
|
tasks_to_complete.append(todo)
|
||||||
|
|
||||||
|
for selection in tasks_to_complete:
|
||||||
|
self._mark_task_complete( selection )
|
||||||
|
else:
|
||||||
|
# no todo items
|
||||||
|
self.do_browse_topics()
|
||||||
|
|
||||||
def create_new_topic_ui(self):
|
def create_new_topic_ui(self):
|
||||||
input_code, input_topic = self.d.inputbox("Creating a new topic for today: {}".format(self._get_current_date()),
|
input_code, input_topic = self.d.inputbox("Creating a new topic for today: {}".format(self._get_current_date()),
|
||||||
|
|
Loading…
Reference in New Issue