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. - Clean-up code and warnings. - Add check for data dumped to pickle file.
- Loading branch information
1 parent
29ba29d
commit 7b552c2
Showing
7 changed files
with
307 additions
and
240 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
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,35 @@ | ||
'''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. | ||
# Todoist tasks are, I think, classes. Let's make Habitica tasks classes, too. | ||
url = 'https://habitica.com/api/v3/tasks/user/' | ||
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.... | ||
|
||
#keeping records of all our 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: | ||
# TODO: handle error cases for response | ||
response = requests.get(url, headers=auth) | ||
if response.ok: | ||
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 = [] | ||
|
||
# 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: | ||
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 |
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
Oops, something went wrong.