def run_task(): import main from habitsUpdating import get_all_habits auth = main.get_started('auth.cfg') habits, response = get_all_habits(auth) for i in range(len(habits)): print('[%s] %s'% (i, habits[i].name)) raw_updating = raw_input("Which habit would you like to complete? Please give me the number. ") try: updating = int(raw_updating) except: print("I'm sorry, I need you to print just the number, please. Try again!") raw_number = raw_input("How many times would you like me to update it? ") try: number = int(raw_number) except: print("I'm sorry, I need you to print just the number, please. Try again!") habit = habits[updating] rList = [] for i in range(number): r = main.complete_hab(habit) rList.append(r) return rList
def run_task(): import main from habitsUpdating import get_all_habits auth = main.get_started('auth.cfg') habits, response = get_all_habits(auth) for i in range(len(habits)): print('[%s] %s' % (i, habits[i].name)) raw_updating = raw_input( "Which habit would you like to complete? Please give me the number. " ) try: updating = int(raw_updating) except: print( "I'm sorry, I need you to print just the number, please. Try again!" ) raw_number = raw_input( "How many times would you like me to update it? ") try: number = int(raw_number) except: print( "I'm sorry, I need you to print just the number, please. Try again!" ) habit = habits[updating] rList = [] for i in range(number): r = main.complete_hab(habit) rList.append(r) return rList
def delete_hab(hab): import requests import json auth = get_started('auth.cfg') url = 'https://habitica.com/api/v3/tasks/' url += hab.task_dict['id'] r = requests.delete(headers=auth, url=url) return r
def get_hab_fromID(tid): import requests import json auth = get_started('auth.cfg') url = 'https://habitica.com/api/v3/tasks/' url += str(tid) r = requests.get(headers=auth, url=url) task = r.json() hab = HabTask(task['data']) return hab
def add_hab_id(tid,hab): import requests import json auth = get_started('auth.cfg') url = 'https://habitica.com/api/v3/tasks/' hab.task_dict['alias'] = str(tid) url += hab.task_dict['id'] data = json.dumps(hab.task_dict) r = requests.put(headers=auth, url=url, data=data) return r
def add_hab_id(tid, hab): import requests import json auth = get_started('auth.cfg') url = 'https://habitica.com/api/v3/tasks/' hab.task_dict['alias'] = str(tid) url += hab.task_dict['id'] data = json.dumps(hab.task_dict) r = requests.put(headers=auth, url=url, data=data) return r
def write_hab_task(task): """ writes a task, if inserted, to Habitica API as a todo. To be added: functionality allowing you to specify things like difficulty """ import requests import json auth = get_started('auth.cfg') url = 'https://habitica.com/api/v3/tasks/user/' # hab = json.dumps(task) r = requests.post(headers=auth, url=url, data=task) return r
def complete_hab(hab): import requests import json auth = get_started('auth.cfg') url = 'https://habitica.com/api/v3/tasks/' url += hab.task_dict['id'] url += '/score/up/' hab_dict = hab.task_dict hab_dict['completed'] = True data = json.dumps(hab_dict) r = requests.post(headers=auth, url=url, data=data) return r
def update_hab(hab): import requests import json from datetime import datetime from main import get_started auth = get_started('auth.cfg') url = 'https://habitica.com/api/v3/tasks/' try: tag = str(hab.task_dict['alias']) except: tag = hab.task_dict['id'] url += tag wanted_keys = ['alias', 'text', 'priority','date'] data = {x : hab.task_dict[x] for x in wanted_keys if x in hab.task_dict} r = requests.put(headers=auth, url=url, data=data) if r.ok == 'No': print(r.text) return r
def update_hab(hab): import requests import json from datetime import datetime from main import get_started auth = get_started('auth.cfg') url = 'https://habitica.com/api/v3/tasks/' try: tag = str(hab.task_dict['alias']) except: tag = hab.task_dict['id'] url += tag wanted_keys = ['alias', 'text', 'priority', 'date'] data = {x: hab.task_dict[x] for x in wanted_keys if x in hab.task_dict} r = requests.put(headers=auth, url=url, data=data) if r.ok == 'No': print(r.text) return r
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. tod_tasks = [] tod_items = tod_user.items tod_tasklist = tod_items.all() today = datetime.now() today_str = today.strftime("%Y-%m-%d") # one_day = timedelta(days=1) # yesterday = datetime.now() - one_day # yesterday_str = yesterday.strftime("%Y-%m-%d")
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)) """ Okay, I want to write a little script that checks whether or not a task is there or not and, if not, ports it. """ pkl_file = open('habtod_matchDict.pkl', 'rb')
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)) """ Okay, I want to write a little script that checks whether or not a task is there or not and, if not, ports it. """
#!/usr/bin/env python import requests import json from hab_task import HabTask import os import main import manaPull auth = main.get_started('auth.cfg') manaPull.cast_all_mana(auth,'valorousPresence') manaPull.assgn_user_attr_pts(auth)