Skip to content

Commit

Permalink
Clean-up.
Browse files Browse the repository at this point in the history
  • Loading branch information
programmerPhysicist committed Nov 29, 2024
1 parent 9e736f3 commit 7a5fdff
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 251 deletions.
22 changes: 11 additions & 11 deletions source/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ def get_todoist_token(configfile):
# Get data from config
if 'Todoist' in config.sections():
try:
tt = config.get('Todoist', 'api-token')
todo_token = config.get('Todoist', 'api-token')

except configparser.NoOptionError as e:
logging.error("Missing option in auth file '" + configfile + "': " + e.message)
except configparser.NoOptionError as error:
logging.error("Missing option in auth file '" + configfile + "': " + error.message)
sys.exit(1)
else:
logging.error("No 'Todoist' section in '%s'", configfile)
sys.exit(1)

return tt
return todo_token


def get_habitica_login(configfile):
Expand All @@ -35,19 +35,19 @@ def get_habitica_login(configfile):
config.read(configfile)

# Get data from config
rv = {}
auth_data = {}
if 'Habitica' in config.sections():
try:
rv = {'url': config.get('Habitica', 'url'),
'x-api-user': config.get('Habitica', 'login'),
'x-api-key': config.get('Habitica', 'password')}
auth_data = {'url': config.get('Habitica', 'url'),
'x-api-user': config.get('Habitica', 'login'),
'x-api-key': config.get('Habitica', 'password')}

except configparser.NoOptionError as e:
logging.error("Missing option in auth file " + configfile + ":" + e.message)
except configparser.NoOptionError as error:
logging.error("Missing option in auth file " + configfile + ":" + error.message)
sys.exit(1)
else:
logging.error("No 'Habitica' section in '%s'", configfile)
sys.exit(1)

# Return auth data as a dictionary
return rv
return auth_data
3 changes: 2 additions & 1 deletion source/habitsUpdating.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import sys, getopt
import main
import requests
import config

def run_task():
import main
from habitsUpdating import get_all_habits
auth = main.get_habitica_login('auth.cfg')
auth = config.get_habitica_login('auth.cfg')
habits, response = get_all_habits(auth)
for i in range(len(habits)):
print('[%s] %s'% (i, habits[i].name))
Expand Down
Loading

0 comments on commit 7a5fdff

Please sign in to comment.