def history(self): import main tod_user = main.tod_login('auth.cfg') activity = tod_user.activity.get(object_type='item', object_id=self.__task_dict['id'], event_type='completed') return activity
from os import path # will let me call files from a specific path import requests import scriptabit import pickle import todoist import main import random import json from hab_task import HabTask from todo_task import TodTask from datetime import datetime # from datetime import timedelta from dateutil import parser #Here's where I'm putting my login stuff for Todoist. tod_user = main.tod_login('auth.cfg') # todayFilter = tod_user.filters.add('todayFilter', 'today') # tod_user.commit() tod_user.sync() tod_projects = tod_user.projects.all() tod_inboxID = tod_projects[0].data['id'] #Telling the site where the config stuff for Habitica can go and get a list of habitica tasks... auth = main.get_started('auth.cfg') # import pdb #Getting all complete and incomplete habitica dailies and todos hab_tasks, r1 = main.get_all_habtasks(auth) #Okay, now I need a list of todoist tasks. How do achieve that.
import json from subprocess import call # useful for running command line commands in python from urllib2 import urlopen from bisect import bisect import logging import netrc import sys from time import sleep from webbrowser import open_new_tab from docopt import docopt from pprint import pprint #Here's where I'm putting my login stuff for Todoist. tod_user = main.tod_login('auth.cfg') tod_projects = tod_user.projects.all() tod_inboxID = tod_projects[0].data['id'] #Telling the site where the config stuff for Habitica can go and get a list of habitica tasks... auth, hbt = main.get_started('auth.cfg') #Getting all complete and incomplete habitica dailies and todos hab_tasks, r1, r2 = main.get_all_habtasks(auth) #Okay, now I need a list of todoist tasks. How do achieve that. tod_tasks = [] tod_items = tod_user.items tod_tasklist = tod_items.all() for i in range(0, len(tod_tasklist)): tod_tasks.append(TodTask(tod_tasklist[i].data))
def syncHistories(matchDict): """ I wanted to see if I could convince recurring habs and tods to sync based on history. Assuming both recur... """ from dates import parse_date_utc from dateutil import parser from datetime import datetime from datetime import timedelta from main import complete_hab, update_hab from main import tod_login tod_user = tod_login('auth.cfg') todList = {} for tid in matchDict: try: matchDict[tid]['recurs'] except: print(tid) matchDict[tid]['recurs'] = matchDict[tid]['tod'].recurring if matchDict[tid]['recurs'] == 'Yes': hab = matchDict[tid]['hab'] tod = matchDict[tid]['tod'] habHistory = hab.history todHistory = tod.history try: lastTod = parser.parse(todHistory[0]['event_date']).date() except: lastTod = tod.due.date() habLen = len(habHistory) - 1 try: lastHab = datetime.fromtimestamp(habHistory[habLen]['date']/1000).date() - timedelta(days=1) except: lastHab = hab.due.date() - timedelta(days=1) lastNow = datetime.today().date() if lastHab > hab.due.date(): newHab = sync_hab2todo(hab, tod) r = update_hab(newHab) if lastTod != lastHab: if lastHab < lastTod and hab.dueToday == True: print("Updating daily hab %s to match tod" % tod.name) r = complete_hab(hab) print(r) elif lastTod < lastHab: # and hab.dueToday == False: if lastTod < lastNow == False: print("Updating daily tod %s to match hab" % tod.name) #fix_tod = tod_user.items.get_by_id(tid) #fix_tod.close() #this to be uncommented in a week or so print(lastTod) print(lastHab) print(lastNow) elif hab.due.date() < lastNow: print("Hey, tod %s looks like it's getting pretty late. Think about tackling that one?" % tod.name) print(lastTod) print(lastHab) print(hab.due) else: print("This one doesn't apply, right?") print(tod.name) print(lastTod) print(lastHab) print(hab.due) tod_user.commit() return matchDict
def history(self): import main tod_user = main.tod_login('auth.cfg') activity = tod_user.activity.get(object_type='item', object_id = self.__task_dict['id'], event_type='completed') return activity
def syncHistories(matchDict): """ I wanted to see if I could convince recurring habs and tods to sync based on history. Assuming both recur... """ from dates import parse_date_utc from dateutil import parser from datetime import datetime from datetime import timedelta from main import complete_hab, update_hab from main import tod_login tod_user = tod_login('auth.cfg') todList = {} for tid in matchDict: try: matchDict[tid]['recurs'] except: print(tid) matchDict[tid]['recurs'] = matchDict[tid]['tod'].recurring if matchDict[tid]['recurs'] == 'Yes': hab = matchDict[tid]['hab'] tod = matchDict[tid]['tod'] habHistory = hab.history todHistory = tod.history try: lastTod = parser.parse(todHistory[0]['event_date']).date() except: lastTod = tod.due.date() habLen = len(habHistory) - 1 try: lastHab = datetime.fromtimestamp( habHistory[habLen]['date'] / 1000).date() - timedelta(days=1) except: lastHab = hab.due.date() - timedelta(days=1) lastNow = datetime.today().date() if lastHab > hab.due.date(): newHab = sync_hab2todo(hab, tod) r = update_hab(newHab) if lastTod != lastHab: if lastHab < lastTod and hab.dueToday == True: print("Updating daily hab %s to match tod" % tod.name) r = complete_hab(hab) print(r) elif lastTod < lastHab: # and hab.dueToday == False: if lastTod < lastNow == False: print("Updating daily tod %s to match hab" % tod.name) #fix_tod = tod_user.items.get_by_id(tid) #fix_tod.close() #this to be uncommented in a week or so print(lastTod) print(lastHab) print(lastNow) elif hab.due.date() < lastNow: print( "Hey, tod %s looks like it's getting pretty late. Think about tackling that one?" % tod.name) print(lastTod) print(lastHab) print(hab.due) else: print("This one doesn't apply, right?") print(tod.name) print(lastTod) print(lastHab) print(hab.due) tod_user.commit() return matchDict