return "/".join(rturl.split(r"\/"))
-class RtMilkManager(object):
+class RtmBackend(object):
"""
Interface with rememberthemilk.com
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
@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("-")