Update of /cvsroot/todo-manager/todo-manager
In directory sc8-pr-cvs1:/tmp/cvs-serv22097
Modified Files:
main.py
Log Message:
Some basic code restructuring like moving interface calls to the end of
functions instead of just sticking them into the middle of functions.
There is also a bug fix for a minor flaw in set_task_value where the
`Finished` flag could be set while `Disable Finish` was active.
Index: main.py
===================================================================
RCS file: /cvsroot/todo-manager/todo-manager/main.py,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- main.py 24 Mar 2003 02:39:13 -0000 1.73
+++ main.py 6 Apr 2003 19:30:59 -0000 1.74
@@ -151,25 +151,25 @@
self.__tasks.append(task)
- # Tell the interfaces that there is a new item
- self.interface_call(ALL, "insert_list_item", name)
-
self.__save_tmpfile()
self.__file_modified = TRUE
+ # Tell the interfaces that there is a new item
+ self.interface_call(ALL, "insert_list_item", name)
+
return TRUE
+ # The interfaces should call this. They should never has plain access to the tasks.
def set_task_value(self, name, key, value, ui=None):
"""Set a value of a task. The first argument is the task name, second
is the setting key, and the last one is the value that the key is set to."""
name = unicode_to_utf8(name)
- value = unicode_to_utf8(value)
+ value = unicode_to_utf8(value)
timefmt = self.get_setting("Core", "timeformat", '')
- # The interfaces should call this. They should never has plain access to the tasks.
found = FALSE
for t in self.__tasks:
if t["Name"] == name:
@@ -179,20 +179,23 @@
# Error checking if the task doesn't exist
if not found: return FALSE
- if t.has_key(key):
+ if t.has_key(key) and value != None:
if key == "Priority":
value = int(value)
if value < 1: value = 1
elif value > 5: value = 5
- elif key == "Finished" and not t["DisableFinish"]:
- value = int(value)
- ft = ("", curtime())[value]
- t["FinishedDate"] = ft
- elif key == "DisableFinish" and value:
+ elif key == "Finished":
+ if not t["DisableFinish"]:
+ value = int(value)
+ ft = ("", curtime())[value]
+ t["FinishedDate"] = ft
+ else: value = FALSE
+ elif key == "DisableFinish":
value = int(value)
- t["DueDate"] = ""
- t["Finished"] = FALSE
- t["FinishedDate"] = ""
+ if value == TRUE:
+ t["DueDate"] = ""
+ t["Finished"] = FALSE
+ t["FinishedDate"] = ""
elif key == "DueDate" and value:
# Check the format of the due date that the user has entered
value = check_time_values(strptime(timefmt, value))
@@ -202,24 +205,20 @@
"is not in the correct format.\nThe format is %s") %self.fmttime(curtime()))
return FALSE
elif key == "Group":
- if value:
- # Split multiple groups into a list
- x = value.split(',')
-
- # Eliminate unwanted white space
- # Tasks can't be in the group 'ALL', this is a global group
- for i in range(len(x)):
- x[i] = x[i].strip()
+ # Split multiple groups into a list
+ x = value.split(',')
- # Remove invalid groups
- if 'ALL' in x: x.remove('ALL')
- if '' in x: x.remove('')
+ # Eliminate unwanted white space
+ # Tasks can't be in the group 'ALL', this is a global group
+ for i in range(len(x)):
+ x[i] = x[i].strip()
- x.sort()
- value = x
+ # Remove invalid groups
+ if 'ALL' in x: x.remove('ALL')
+ if '' in x: x.remove('')
- else:
- value = []
+ x.sort()
+ value = x
t[key] = value
@@ -287,13 +286,15 @@
for t in self.__tasks:
if t["Name"] == name:
self.__tasks.remove(t)
- self.interface_call(ALL, "remove_list_item", name)
- self.interface_call(ALL, "update_list_groups", self.__get_task_groups())
self.__save_tmpfile()
self.__file_modified = TRUE
+ self.interface_call(ALL, "remove_list_item", name)
+ self.interface_call(ALL, "update_list_groups", self.__get_task_groups())
+
+
return TRUE
return FALSE
@@ -837,6 +838,9 @@
found = TRUE
break
+ # If the plugin wasn't found then just return
+ if not found: return
+
if kw.has_key("tasks"):
# Get the tasks that the user wants to use
new_tasks = []
@@ -846,9 +850,6 @@
new_tasks.append(t)
else:
new_tasks = self.__dup_task_list()
-
- # If the plugin wasn't found then just return
- if not found: return
if p['type'] == 'file_import':
self.__ext_load_file(func=p['function'], desc=p['name'], ext=p['format'], ui=ui)
|