return "/".join(rturl.split(r"\/"))
-class RtMilkManager(object):
+class RtmBackend(object):
"""
Interface with rememberthemilk.com
@todo Add interface for task estimate
@todo Add interface for task location
@todo Add interface for task url
- @todo Add interface for task notes
@todo Add undo support
"""
API_KEY = '71f471f7c6ecdda6def341967686fe05'
self._timeline = resp.timeline
self._lists = []
+ def save(self):
+ pass
+
+ def load(self):
+ pass
+
+ def add_project(self, name):
+ rsp = self._rtm.lists.add(
+ timeline=self._timeline,
+ name=name,
+ )
+ assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+ self._lists = []
+
+ def set_project_name(self, projId, name):
+ rsp = self._rtm.lists.setName(
+ timeline=self._timeline,
+ list_id=projId,
+ name=name,
+ )
+ assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+ self._lists = []
+
+ def set_project_visibility(self, projId, visibility):
+ action = self._rtm.lists.unarchive if visibility else self._rtm.lists.archive
+ rsp = action(
+ timeline=self._timeline,
+ list_id=projId,
+ )
+ assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+ self._lists = []
+
def get_projects(self):
if len(self._lists) == 0:
self._populate_projects()
assert len(projs) == 1, "%r: %r / %r" % (projId, projs, self._lists)
return projs[0]
- def get_project_names(self):
- return (list["name"] for list in self.get_projects)
-
def lookup_project(self, projName):
"""
From a project's name, returns the project's details
"completedDate": task.completed,
"priority": task.priority,
"estimate": task.estimate,
- "notes": list(self._get_notes(taskId, taskSeries.notes)),
+ "notes": dict((
+ (note["id"], note)
+ for note in self._get_notes(taskId, taskSeries.notes)
+ )),
}
taskDetails = self._parse_task_details(rawTaskDetails)
yield taskDetails
)
assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+ def add_note(self, taskId, noteTitle, noteBody):
+ projId, seriesId, taskId = self._unpack_ids(taskId)
+
+ rsp = self._rtm.tasks.notes.add(
+ timeline=self._timeline,
+ list_id=projId,
+ taskseries_id=seriesId,
+ task_id=taskId,
+ note_title=noteTitle,
+ note_text=noteBody,
+ )
+ assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+
+ def update_note(self, noteId, noteTitle, noteBody):
+ projId, seriesId, taskId, note = self._unpack_ids(noteId)
+
+ rsp = self._rtm.tasks.notes.edit(
+ timeline=self._timeline,
+ note_id=noteId,
+ note_title=noteTitle,
+ note_text=noteBody,
+ )
+ assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+
+ def delete_note(self, noteId):
+ projId, seriesId, taskId, noteId = self._unpack_ids(noteId)
+
+ rsp = self._rtm.tasks.notes.delete(
+ timeline=self._timeline,
+ note_id=noteId,
+ )
+ assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+
@staticmethod
def _pack_ids(*ids):
"""
- >>> RtMilkManager._pack_ids(123, 456)
+ >>> RtmBackend._pack_ids(123, 456)
'123-456'
"""
return "-".join((str(id) for id in ids))
@staticmethod
def _unpack_ids(ids):
"""
- >>> RtMilkManager._unpack_ids("123-456")
+ >>> RtmBackend._unpack_ids("123-456")
['123', '456']
"""
return ids.split("-")