forked from jenmei/Habitica-todo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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. - Do some clean-up. - Add check for data dumped to pickle file.
- Loading branch information
1 parent
662f37c
commit 5d656f4
Showing
5 changed files
with
286 additions
and
238 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
'''Habitica related functions''' | ||
# TODO: convert to class that makes all | ||
# calls to Habitica | ||
import requests | ||
from hab_task import HabTask | ||
|
||
def get_all_habtasks(auth): | ||
#Todoist tasks are, I think, classes. Let's make Habitica tasks classes, too. | ||
url = 'https://habitica.com/api/v3/tasks/user/' | ||
# TODO: handle error cases for response | ||
response = requests.get(url,headers=auth) | ||
hab_raw = response.json() | ||
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.... | ||
|
||
if response.ok == True: | ||
hab_raw = response.json() | ||
"""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....""" | ||
hab_tasklist = hab_raw['data'] | ||
else: | ||
hab_tasklist = [] | ||
print(response.reason) | ||
|
||
#keeping records of all our tasks | ||
hab_tasks = [] | ||
hab_tasks = [] | ||
|
||
#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... | ||
for task in hab_tasklist: | ||
for task in hab_tasklist: | ||
item = HabTask(task) | ||
if item.category == 'reward': | ||
pass | ||
elif item.category == 'habit': | ||
elif item.category == 'habit': | ||
pass | ||
else: | ||
hab_tasks.append(item) | ||
return(hab_tasks, response) | ||
return hab_tasks |
Oops, something went wrong.