16
16
import random
17
17
import json
18
18
#from hab_task import HabTask
19
- # from todo_task import TodTask
19
+ from todo_task import TodTask
20
20
from datetime import datetime
21
21
from datetime import timedelta
22
22
# from dateutil import parser
@@ -46,7 +46,11 @@ def get_tasks(token):
46
46
todoToken = config .getTodoistToken ('auth.cfg' )
47
47
48
48
#Okay, now I need a list of todoist tasks.
49
- todoTasks , todoApi = get_tasks (todoToken )
49
+ todoist_tasks , todoApi = get_tasks (todoToken ) # todoist_tasks used to be tod_tasks
50
+
51
+ tod_tasks = []
52
+ for i in range (0 , len (todoist_tasks )):
53
+ tod_tasks .append (TodTask (todoist_tasks [i ]))
50
54
51
55
# date stuff
52
56
today = datetime .now ()
@@ -55,38 +59,26 @@ def get_tasks(token):
55
59
yesterday = datetime .now () - one_day
56
60
yesterday_str = yesterday .strftime ("%Y-%m-%d" )
57
61
58
- overdue_tasks = [] # overdue_tasks used to be tod_tasklist
59
- todoist_tasks = [] # todoist_tasks used to be tod_tasks
60
- other_tasks = []
61
- for task in todoTasks :
62
- if task .due != None and not task .is_completed :
63
- # filter by due date
64
- if task .due .datetime == None and task .due .date != None :
65
- dateStr = task .due .date
66
- if dateStr == today_str :
67
- todoist_tasks .append (task )
68
- overdue_tasks .append (task )
69
- elif dateStr == yesterday_str :
70
- overdue_tasks .append (task )
71
- else :
72
- other_tasks .append (task )
73
-
74
62
"""
75
63
Okay, I want to write a little script that checks whether or not a task is there or not and, if not, ports it.
76
64
"""
77
65
matchDict = main .openMatchDict ()
78
66
79
67
#Also, update lists of tasks with matchDict file...
80
- matchDict = main .update_tod_matchDict (todoist_tasks , matchDict )
68
+ matchDict = main .update_tod_matchDict (tod_tasks , matchDict )
81
69
matchDict = main .update_hab_matchDict (hab_tasks , matchDict )
82
70
83
71
#We'll want to just... pull all the unmatched completed tasks out of our lists of tasks. Yeah?
84
- tod_uniq , hab_uniq = main .get_uniqs (matchDict , todoist_tasks , hab_tasks )
72
+ tod_uniq , hab_uniq = main .get_uniqs (matchDict , tod_tasks , hab_tasks )
85
73
86
74
#Okay, so what if there are two matched tasks in the two uniq lists that really should be paired?
87
75
matchDict = main .check_newMatches (matchDict ,tod_uniq ,hab_uniq )
88
76
89
77
#Here anything new in todoist gets added to habitica
78
+ tod_uniq = []
79
+ hab_uniq = []
80
+ tod_uniq , hab_uniq = main .getNewTodoTasks (matchDict , tod_tasks , hab_tasks )
81
+
90
82
for tod in tod_uniq :
91
83
tid = tod .id
92
84
if tod .recurring == "Yes" :
0 commit comments