import toolbox
import gtk_toolbox
import rtm_backend
-import rtmapi
+import rtm_api
def abbreviate(text, expectedLen):
def get_token(username, apiKey, secret):
token = None
- rtm = rtmapi.RTMapi(username, apiKey, secret, token)
+ rtm = rtm_api.RTMapi(username, apiKey, secret, token)
authURL = rtm.getAuthURL()
webbrowser.open(authURL)
self._manager = rtm_backend.RtMilkManager(*credentials)
self._credentials = credentials
return # Login succeeded
- except rtmapi.AuthStateMachine.NoData:
+ except rtm_api.AuthStateMachine.NoData:
# Login failed, grab new credentials
credentials = get_credentials(self._credentialsDialog)
# @todo Look into using a button for notes and links, and labels for all else
currentProject = self._get_project()
projId = self._manager.lookup_project(currentProject)["id"]
- for taskDetails in self._manager.get_tasks_with_details(projId):
+ sortedTasks = list(self._manager.get_tasks_with_details(projId))
+ sortedTasks.sort(key = lambda taskDetails: (taskDetails["priority"].get_nothrow(1000), taskDetails["dueDate"].get_nothrow(datetime.datetime.max)))
+ for taskDetails in sortedTasks:
show = self._showCompleted if taskDetails["isCompleted"] else self._showIncomplete
if not show:
continue
id = taskDetails["id"]
isCompleted = taskDetails["isCompleted"]
name = abbreviate(taskDetails["name"], 100)
- priority = taskDetails["priority"]
- dueDescription = taskDetails["dueDate"]
- if dueDescription:
- dueDate = datetime.datetime.strptime(dueDescription, "%Y-%m-%dT%H:%M:%SZ")
+ priority = str(taskDetails["priority"].get_nothrow(""))
+ if taskDetails["dueDate"].is_good():
+ dueDate = taskDetails["dueDate"].get()
+ dueDescription = dueDate.strftime("%Y-%m-%d %H:%M:%S")
fuzzyDue = toolbox.to_fuzzy_date(dueDate)
else:
+ dueDescription = ""
fuzzyDue = ""
linkDisplay = taskDetails["url"]