Commits

Tetsuya Morimoto committed e8e4340

fixed to check a task list which is iterable or not

Comments (0)

Files changed (1)

 def createApp(rtm):
     rspTasks = rtm.tasks.getList(filter='dueWithin:"1 week of today"')
     tasks = []
-    for l in rspTasks.tasks.list:
-        # XXX: taskseries *may* be a list 
-        if isinstance(l.taskseries, (list, tuple)):
-            for t in l.taskseries:
-                tasks.append(t.name)
-        else:
-            tasks.append(l.taskseries.name)
+    if hasattr(rspTasks.tasks.list, "__getitem__"):
+        for l in rspTasks.tasks.list:
+            # XXX: taskseries *may* be a list
+            if isinstance(l.taskseries, (list, tuple)):
+                for t in l.taskseries:
+                    tasks.append(t.name)
+            else:
+                tasks.append(l.taskseries.name)
     print tasks
+    if not tasks:
+        tasks.append('No tasks due within a week')
 
     root = Tk()
     root.title('My tasks due within a week')
         except IndexError:
             token = None
         test(api_key, secret, token)
-    
-