resp = self._rtm.timelines.create()
self._timeline = resp.timeline
self._lists = []
- self._locations = []
def get_projects(self):
if len(self._lists) == 0:
yield list
def get_project(self, projId):
- if len(self._lists) == 0:
- self._populate_projects()
-
- proj = [proj for proj in self._lists if projId == proj["id"]]
+ proj = [proj for proj in self.get_projects() if projId == proj["id"]]
assert len(proj) == 1, "%r / %r" % (proj, self._lists)
return proj[0]
def get_project_names(self):
- if len(self._lists) == 0:
- self._populate_projects()
-
- return (list["name"] for list in self._lists)
-
- def get_locations(self):
- if len(self._locations) == 0:
- self._populate_locations()
-
- return self._locations
+ return (list["name"] for list in self.get_projects)
def lookup_project(self, projName):
- if len(self._lists) == 0:
- self._populate_projects()
- todoList = [list for list in self._lists if list["name"] == projName]
+ """
+ From a project's name, returns the project's details
+ """
+ todoList = [list for list in self.get_projects() if list["name"] == projName]
assert len(todoList) == 1, "Wrong number of lists found for %s, in %r" % (projName, todoList)
return todoList[0]
+ def get_locations(self):
+ rsp = self._rtm.locations.getList()
+ assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+ locations = [
+ dict((
+ ("name", t.name),
+ ("id", t.id),
+ ("longitude", t.longitude),
+ ("latitude", t.latitude),
+ ("address", t.address),
+ ))
+ for t in rsp.locations
+ ]
+ return locations
+
def get_tasks_with_details(self, projId):
for taskSeries in self._get_taskseries(projId):
for task in self._get_tasks(taskSeries):
))
for t in rsp.lists.list
))
-
- def _populate_locations(self):
- rsp = self._rtm.locations.getList()
- assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
- del self._locations[:]
- self._locations.extend((
- dict((
- ("name", t.name),
- ("id", t.id),
- ("longitude", t.longitude),
- ("latitude", t.latitude),
- ("address", t.address),
- ))
- for t in rsp.locations
- ))