Skip to content

Commit

Permalink
Fixes:
Browse files Browse the repository at this point in the history
    - 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
programmerPhysicist committed Jul 30, 2024
1 parent 662f37c commit 5d656f4
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 238 deletions.
File renamed without changes.
26 changes: 18 additions & 8 deletions source/habitica.py
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
Loading

0 comments on commit 5d656f4

Please sign in to comment.