Skip to content

Commit 143d20c

Browse files
Merge branch 'alpha'
2 parents 7b9994e + ab78100 commit 143d20c

14 files changed

+202
-84
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ That means that if you create a task in Todoist and then check it off, right now
1313

1414
## INSTALLATION
1515

16-
There are two dependencies you'll need to install, and the commands to install them are as follows:
16+
There are a number dependencies you'll need to install, and the commands to install them are as follows:
1717
```
1818
pip install todoist-python
1919
pip install requests
20+
pip install scriptabit
21+
pip install tzlocal
22+
pip install iso8601
23+
pip install python-dateutil
2024
```
2125
Finally, you need to add your API tokens to the `Habitica-Plus-Todoist/source/auth.cfg.example` file. You can find your Habitica API User ID and API key by visiting https://habitica.com/user/settings/api while logged in, and your Todoist API token can be found by visiting https://todoist.com/prefs/integrations while logged in. Once you've added these tokens, you should rename the file to `Habitica-Plus-Todoist/source/auth.cfg` (remove the '.example' at the end).
2226

@@ -35,7 +39,7 @@ If you'd like to change how the sync interprets difficulty or priority, please e
3539

3640
## USAGE
3741

38-
Try running `python source/oneWaySync.py` in your terminal.
42+
Try running `python oneWaySync.py` in your terminal. (You have to run the command from the same directory that auth.cfg exists in).
3943

4044
## Credit
4145

dist/habitica-todo-1.2.tar.gz

-11.9 KB
Binary file not shown.

dist/habitica-todo-1.3.tar.gz

-11.9 KB
Binary file not shown.

dist/habiticaTodo-1.2.0.tar.gz

-11.7 KB
Binary file not shown.

dist/habitica_todo-1.2.0.tar.gz

-11.8 KB
Binary file not shown.

habiticaPlusTodoist.egg-info/PKG-INFO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Metadata-Version: 1.0
22
Name: Habitica-Plus-Todoist
3-
Version: 1.2.0.1
3+
Version: 2.0.1
44
Summary: An API app for syncing todoist and habitica tasks
5-
Home-page: https://github.com/eringiglio/Habitica-Plus-Todoist
5+
Home-page: https://github.com/programmerPhysicist/Habitica-Plus-Todoist
66
Author: UNKNOWN
77
Author-email: UNKNOWN
88
License: UNKNOWN

scripts/runHabitica-todo.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
# Run habiticaTodo, avoid proxy.
3+
unset http_proxy
4+
unset https_proxy
5+
6+
pwd
7+
cd source
8+
python3.9 oneWaySync.py

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
setup(
66
name='Habitica-Plus-Todoist',
7-
version='1.2.0.1',
8-
url='https://github.com/eringiglio/Habitica-Plus-Todoist',
7+
version='2.0.1',
8+
url='https://github.com/programmerPhysicist/Habitica-Plus-Todoist',
99
description='An API app for syncing todoist and habitica tasks',
1010
packages=['Habitica-Plus-Todoist'],
1111
zip_safe=False)

source/config.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
'''This file deals with config related functions'''
2+
import logging
3+
import configparser
4+
5+
def getTodoistToken(configfile):
6+
logging.debug('Loading todoist auth data from %s' % configfile)
7+
8+
try:
9+
cf = open(configfile)
10+
except IOError:
11+
logging.error("Unable to find '%s'." % configfile)
12+
exit(1)
13+
14+
config = configparser.SafeConfigParser()
15+
config.readfp(cf)
16+
17+
cf.close()
18+
19+
# Get data from config
20+
try:
21+
tt = config.get('Todoist', 'api-token')
22+
23+
except configparser.NoSectionError:
24+
logging.error("No 'Todoist' section in '%s'" % configfile)
25+
exit(1)
26+
27+
except configparser.NoOptionError as e:
28+
logging.error("Missing option in auth file '%s': %s" % (configfile, e.message))
29+
exit(1)
30+
31+
return tt
32+
33+
def get_started(configfile):
34+
"""Get Habitica authentication data from the AUTH_CONF file."""
35+
36+
logging.debug('Loading habitica auth data from %s' % configfile)
37+
38+
try:
39+
cf = open(configfile)
40+
except IOError:
41+
logging.error("Unable to find '%s'." % configfile)
42+
exit(1)
43+
44+
config = configparser.SafeConfigParser()
45+
config.readfp(cf)
46+
47+
cf.close()
48+
49+
# Get data from config
50+
rv = {}
51+
try:
52+
rv = {'url': config.get('Habitica', 'url'),
53+
'x-api-user': config.get('Habitica', 'login'),
54+
'x-api-key': config.get('Habitica', 'password')}
55+
56+
except configparser.NoSectionError:
57+
logging.error("No 'Habitica' section in '%s'" % configfile)
58+
exit(1)
59+
60+
except configparser.NoOptionError as e:
61+
logging.error("Missing option in auth file '%s': %s"
62+
% (configfile, e.message))
63+
exit(1)
64+
65+
# Return auth data as a dictionnary
66+
return rv

source/habitica.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'''Habitica related functions'''
2+
import requests
3+
from hab_task import HabTask
4+
5+
def get_all_habtasks(auth):
6+
#Todoist tasks are, I think, classes. Let's make Habitica tasks classes, too.
7+
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+
for task in hab_tasklist:
17+
item = HabTask(task)
18+
if item.category == 'reward':
19+
pass
20+
elif item.category == 'habit':
21+
pass
22+
else:
23+
hab_tasks.append(item)
24+
return(hab_tasks, response)

0 commit comments

Comments
 (0)