You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Get completed tasks in Todoist to be completed in Habitica. Clean up.
- Modify code to work better for testing.
- Fix issue with date not syncing. Also partially fix#3 issue.
- Improve error handling. Add sleep for rate limiting.
- Clean-up code and warnings.
- Add check for data dumped to pickle file.
#Todoist tasks are, I think, classes. Let's make Habitica tasks classes, too.
8
+
#Todoist tasks are, I think, classes. Let's make Habitica tasks classes, too.
7
9
url='https://habitica.com/api/v3/tasks/user/'
8
-
response=requests.get(url,headers=auth)
9
-
hab_raw=response.json()
10
-
hab_tasklist=hab_raw['data'] #FINALLY getting something I can work with... this will be a list of dicts I want to turn into a list of objects with class hab_tasks. Hrm. Weeeelll, if I make a class elsewhere....
11
-
12
-
#keeping records of all our tasks
13
-
hab_tasks= []
14
-
15
-
#No habits right now, I'm afraid, in hab_tasks--Todoist gets upset. So we're going to make a list of dailies and todos instead...
16
-
fortaskinhab_tasklist:
10
+
# TODO: handle error cases for response
11
+
response=requests.get(url, headers=auth)
12
+
ifresponse.ok:
13
+
hab_raw=response.json()
14
+
# FINALLY getting something I can work with... this will be a list of
15
+
# dicts I want to turn into a list of objects with class hab_tasks.
16
+
# Hrm. Weeeelll, if I make a class elsewhere....
17
+
hab_tasklist=hab_raw['data']
18
+
else:
19
+
hab_tasklist= []
20
+
print(response.reason)
21
+
22
+
# keeping records of all our tasks
23
+
hab_tasks= []
24
+
25
+
# No habits right now, I'm afraid, in hab_tasks-Todoist gets upset. So we're going to make a list of dailies and
#Todoist tasks are, I think, classes. Let's make Habitica tasks classes, too.
194
+
#Todoist tasks are, I think, classes. Let's make Habitica tasks classes, too.
201
195
url='https://habitica.com/api/v3/tasks/user/'
202
-
response=requests.get(url,headers=auth)
196
+
response=requests.get(url,headers=auth)
203
197
hab_raw=response.json()
204
-
hab_tasklist=hab_raw['data'] #FINALLY getting something I can work with... this will be a list of dicts I want to turn into a list of objects with class hab_tasks. Hrm. Weeeelll, if I make a class elsewhere....
198
+
# FINALLY getting something I can work with... this will be a list of dicts I want to turn into a list of objects
199
+
# with class hab_tasks. Hrm. Weeeelll, if I make a class elsewhere....
200
+
hab_tasklist=hab_raw['data']
205
201
206
-
#keeping records of all our tasks
202
+
#keeping records of all our tasks
207
203
hab_tasks= []
208
204
209
-
#No habits right now, I'm afraid, in hab_tasks--Todoist gets upset. So we're going to make a list of dailies and todos instead...
205
+
#No habits right now, I'm afraid, in hab_tasks--Todoist gets upset. So we're going to make a list of dailies and todos instead...
210
206
fortaskinhab_tasklist:
211
207
item=HabTask(task)
212
208
ifitem.category=='reward':
@@ -215,19 +211,25 @@ def get_all_habtasks(auth):
215
211
pass
216
212
else:
217
213
hab_tasks.append(item)
218
-
return(hab_tasks, response)
214
+
return (hab_tasks, response)
215
+
219
216
220
217
defget_hab_fromID(tid):
221
218
importrequests
222
219
importjson
223
220
auth=get_started('auth.cfg')
224
221
url='https://habitica.com/api/v3/tasks/'
225
222
url+=str(tid)
226
-
r=requests.get(headers=auth, url=url)
227
-
task=r.json()
228
-
hab=HabTask(task['data'])
223
+
response=requests.get(headers=auth, url=url)
224
+
ifresponse.ok:
225
+
task=response.json()
226
+
hab=HabTask(task['data'])
227
+
else:
228
+
# TODO: log error
229
+
hab=HabTask()
229
230
returnhab
230
231
232
+
231
233
defget_started(configfile):
232
234
"""Get Habitica authentication data from the AUTH_CONF file."""
0 commit comments