Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NEETmode productivity tool in python
import ast
import pyfiglet
import time
from random import randint
from colorama import init
init()
from colorama import Fore, Back, Style
import datetime
person_list = []
now = datetime.datetime.now()
current_date = now.strftime("%Y-%m-%d")
activities_list = ""
profile_stats_list = ""
state = "menu"
choice = 'Main Menu'
menu_input = ''
header_text = " the best executive function tool ever "
ascii_banner = pyfiglet.figlet_format("NEET MODE")
ascii_goodbye = pyfiglet.figlet_format("GOODBYE")
total_exp = 0
max_days_perfect = 0
completed_day = False
current_days_perfect = 0
total_days_perfect = 0
total_days_imperfect = 0
total_tasks_completed = 0
total_tasks_incompleted = 0
def get_current_date():
global now, current_date
now = datetime.datetime.now()
current_date = now.strftime("%Y-%m-%d")
return(current_date)
def load_profile():
global profile_stats_list, total_tasks_completed, total_tasks_incompleted, total_days_perfect, total_days_imperfect, current_days_perfect, max_days_perfect, total_exp
profile_stats_txt = open("profile_stats.txt", "r")
profile_stats_list = ast.literal_eval(profile_stats_txt.read())
total_tasks_completed = profile_stats_list[0]
total_tasks_incompleted = profile_stats_list[1]
total_days_perfect = profile_stats_list[2]
total_days_imperfect = profile_stats_list[3]
current_days_perfect = profile_stats_list[4]
max_days_perfect = profile_stats_list[5]
total_exp = profile_stats_list[6]
def load_activities_history():
activities_history_txt = open("activities_history.txt", "r")
return(ast.literal_eval(activities_history_txt.read()))
def load_current_activities():
current_activities_txt = open("current_activities.txt", "r")
generate_activities(ast.literal_eval(current_activities_txt.read()))
def write_profile():
global profile_stats_list, total_tasks_completed, total_tasks_incompleted, total_days_perfect, total_days_imperfect, current_days_perfect, max_days_perfect, total_exp
profile_stats_list = [total_tasks_completed, total_tasks_incompleted, total_days_perfect, total_days_imperfect, current_days_perfect, max_days_perfect, total_exp]
profile_stats_text = open("profile_stats.txt","w")#write mode
profile_stats_text.write(str(profile_stats_list))
profile_stats_text.close()
def write_activities_history(activities_history_list):
activities_history = open("activities_history.txt","w")#write mode
activities_history.write(str(activities_history_list))
activities_history.close()
def print_profile_stats():
print('\nGeneral Stats: ')
print_medium_spacer()
print(get_profile_stats_string())
print_medium_spacer()
print_paragraph_whitespace()
def get_exp_stats_str():
exp_level_list = []
for x in range(1, 100):
exp_level_list.append(int(30 + pow(1.3, x)))
i = 0
for exp_cap in exp_level_list:
i += 1
if total_exp < exp_cap: exp_level = i; exp_level_cap = exp_cap; exp_level_cap_old = int(30 + pow(1.3, i - 1)); break
return 'Level ' + str(exp_level) + ' ' + get_percentage_bar_str((total_exp - exp_level_cap_old)/(exp_level_cap - exp_level_cap_old)) + ' ' + str(total_exp - exp_level_cap_old) + '/' + str(exp_level_cap - exp_level_cap_old) + ' ' + str(total_exp) + 'EXP'
def get_profile_stats_string():
return_str = 'TOTAL Complete: ' + str(total_tasks_completed) + ', Incomplete: ' + str(total_tasks_incompleted) + '\n' + get_percentage_bar_str(total_tasks_completed/(total_tasks_completed+total_tasks_incompleted)) + ' Completion Rate \nStreak: ' + str(current_days_perfect) + ', Record Streak: ' + str(max_days_perfect) + '\nTOTAL Perfect: ' + str(total_days_perfect) + ', Imperfect: ' + str(total_days_imperfect) + '\n' + get_exp_stats_str() + ' '
return return_str
def print_header():
global header_text, ascii_banner
clear_screen()
header_spacer = ''
for letter in header_text:
header_spacer += '-'
print(ascii_banner, '\n', header_spacer, '\n', header_text, '\n', header_spacer, '\n')
def get_percentage_bar_str(percentage):
real_percentage = percentage * 100
percentage *= 100
percentage_string = "[----------]"
percentage_string = list(percentage_string)
i = 0
while percentage - 10 >= 0:
i += 1
percentage -= 10
percentage_string[i] = "X"
while percentage - 5 >= 0:
i += 1
percentage -= 5
percentage_string[i] = "x"
return (''.join(percentage_string) + ' ' + str('{:3.0f}'.format(real_percentage)) + '%')
def add_activity():
global activities_list
get_activities_list()
activity = {}
activity['act_name'] = input("Enter Activity Name: ")
activity['act_desc'] = input("Enter Activity Description: ")
activity['act_type'] = input("Enter Activity Type, (t)ime or (r)ange: ") # time or amount based eg 1 hour reading or 20 pages read
activity['act_unit'] = input("Enter Activity Unit of Measure, eg 'minutes' or 'pages': ")
activity['act_amnt_min'] = input("Enter Activity Min Amount: ")
activity['act_amnt_max'] = input("Enter Activity Max Amount: ") # 1 hour/page to 10 hours/pages
activity['act_freq'] = input("Enter Average Frequency Per Week (1-7) Activity Occurs: ")
activities_list = ast.literal_eval(activities_list)
activities_list = list(activities_list)
activities_list.append(activity)
write_activities_list(activities_list)
def write_activities_list(activities_list):
act_list = open("activities.txt","w")#write mode
act_list.write(str(activities_list))
act_list.close()
def write_current_activities_list(activities_list):
act_list = open("current_activities.txt","w")#write mode
act_list.write(str(activities_list))
act_list.close()
def ranged_integer_input(message, min_input, max_input):
while True:
try:
int_input = input(message)
if int_input == "q":
break
int_input = int(int_input)
while int(int_input) < min_input or int(int_input) > max_input:
print("ERROR: Out of choice range")
int_input = int(input(message))
break
except:
print("ERROR: Invalid input (not integer)")
return int_input
def edit_activity():
global activities_list
print_activities()
activities_list = ast.literal_eval(activities_list)
activities_list = list(activities_list)
print_medium_spacer()
activity_to_edit = ranged_integer_input("# of activity to edit, 'q' to quit to menu: ", 1, len(activities_list))
if activity_to_edit != "q":
activity_to_edit -= 1
activity = activities_list[activity_to_edit]
field_to_edit = ranged_integer_input("Edit: 1. Name, 2. Description, 3. Type, 4. Unit of Measure, 5. Amount Min, 6. Amount Max, 7. Frequency per week: ", 1,7)
print_medium_spacer()
if field_to_edit == 1: value_to_edit = activity['act_name']; activity['act_name'] = input('Old value: ' + value_to_edit + '. Replace with: ')
elif field_to_edit == 2: value_to_edit = activity['act_desc']; activity['act_desc'] = input('Old value: ' + value_to_edit + '. Replace with: ')
elif field_to_edit == 3: value_to_edit = activity['act_type']; activity['act_type'] = input('Old value: ' + value_to_edit + '. Replace with: ')
elif field_to_edit == 4: value_to_edit = activity['act_unit']; activity['act_unit'] = input('Old value: ' + value_to_edit + '. Replace with: ')
elif field_to_edit == 5: value_to_edit = activity['act_amnt_min']; activity['act_amnt_min'] = input('Old value: ' + value_to_edit + '. Replace with: ')
elif field_to_edit == 6: value_to_edit = activity['act_amnt_max']; activity['act_amnt_max'] = input('Old value: ' + value_to_edit + '. Replace with: ')
elif field_to_edit == 7: value_to_edit = activity['act_freq']; activity['act_freq'] = input('Old value: ' + value_to_edit + '. Replace with: ')
write_activities_list(activities_list)
clear_screen()
print_header()
print_activities()
else:
sure_input = input("Are you sure? y/n: ")
while sure_input not in ["y","n"]:
sure_input = input("Invalid choice. \nAre you sure? y/n: ")
if sure_input == "y":
state = "menu"
def clear_screen():
print('\n'*40)
def print_medium_spacer():
print('---------------')
def print_paragraph_whitespace():
print('\n\n')
def generate_activities(current_activities_list = []):
global activities_list, completed_day, generated_activities, total_exp
global profile_stats_list, total_tasks_completed, total_tasks_incompleted, total_days_perfect, total_days_imperfect, current_days_perfect, max_days_perfect
random_boost = randint(30,60)
activity_names = ''
completed_day = False
current_tasks_completed = 0
total_minutes = 0
loaded_first_gen = False
completed_minutes = 0
get_activities_list()
print('Generating list of activities: \n')
if current_activities_list == []:
i = 0; activity_list = []
for activity in ast.literal_eval(activities_list):
if randint(1, 7) <= int(activity['act_freq']):
i += 1
semi_random_amount = randint(int(activity['act_amnt_min']), int(activity['act_amnt_max']))
activity_list.append([activity['act_name'], activity['act_desc'], 0, semi_random_amount, activity['act_unit']])
else: activity_list = current_activities_list; i = len(current_activities_list); loaded_first_gen = True
for activity in activity_list:
if activity[4] == "minutes": total_minutes += activity[3]
if loaded_first_gen == False: total_tasks_incompleted += i
if loaded_first_gen == True: loaded_first_gen = False
state = "activities"
while state == "activities":
print_header()
print('\n')
print('Daily point multiplier x' + str('{:1.2f}'.format(1 + random_boost/100)) + ', ' + str(total_exp) + 'EXP; ' + str(i) + ' activities for today:')
print_medium_spacer()
i2 = 0
percentage_total = 0
for activity in activity_list:
i2 += 1
activity_percent = activity[2]/activity[3]
if i2 % 2:
print(Style.DIM + Fore.WHITE + str('{:2.0f}'.format(i2)), get_percentage_bar_str(activity[2]/activity[3]), activity[0], '-', activity[1], '-', str(activity[2]) + '/' + str(activity[3]), activity[4] + ';', activity[3] - activity[2], activity[4], 'left', Style.RESET_ALL)
else:
print(str('{:2.0f}'.format(i2)), get_percentage_bar_str(activity[2]/activity[3]), activity[0], '-', activity[1], '-', str(activity[2]) + '/' + str(activity[3]), activity[4] + ';', activity[3] - activity[2], activity[4], 'left')
percentage_total += activity[2]/activity[3]
print_medium_spacer()
write_current_activities_list(activity_list)
percentage_total = (percentage_total/i2)
if current_tasks_completed == i2:
print_medium_spacer()
print("All daily activities completed! +300 EXP")
total_exp += 300
print_medium_spacer()
total_days_perfect += 1
current_days_perfect += 1
completed_day = True
if current_days_perfect > max_days_perfect:
max_days_perfect = current_days_perfect
print(' A', get_percentage_bar_str(current_tasks_completed/i2), current_tasks_completed, '/', i2, 'Activities')
if total_minutes > 0: print(' M', get_percentage_bar_str(completed_minutes/total_minutes), completed_minutes, '/', total_minutes, 'Minutes')
print_medium_spacer()
print(' T', get_percentage_bar_str(percentage_total))
print_profile_stats()
write_profile()
activity_to_update = ranged_integer_input("# activity to update, q' to quit to menu:", 1, i2)
if activity_to_update not in ["q","m"]:
activity_to_update -= 1
if completed_day: total_exp -= 300
if activity_list[activity_to_update][2]/activity_list[activity_to_update][3] == 1 : total_exp -= (100 + random_boost); total_tasks_completed -= 1; current_tasks_completed -= 1; total_tasks_incompleted += 1; completed_day = False;
pre_modify_amount = activity_list[activity_to_update][2]
activity_list[activity_to_update][2] = int(ranged_integer_input(activity_list[activity_to_update][0] + ' completed ' + activity_list[activity_to_update][4] + ": ", 0, activity_list[activity_to_update][3]))
if activity_list[activity_to_update][4] == "minutes":
completed_minutes += activity_list[activity_to_update][2] - pre_modify_amount
if activity_list[activity_to_update][2]/activity_list[activity_to_update][3] == 1 : total_exp += (100 + random_boost); total_tasks_completed += 1; current_tasks_completed += 1; total_tasks_incompleted -= 1
else:
sure_input = input("Are you sure? y/n: ")
while sure_input not in ["y","n"]:
sure_input = input("Invalid choice. \nAre you sure? y/n: ")
if sure_input == "y":
current_date = get_current_date()
complete_activity_list = []
incomplete_activity_list = []
for activity in activity_list:
i += 1
activity_str = get_percentage_bar_str(activity[2]/activity[3]) + ' ' + str(activity[0]) + "; " + str(activity[1]) + " " + str(activity[2]) + "/" + str(activity[3]) + " " + str(activity[4])
activity_percent = activity[2]/activity[3]
if activity_percent == 1: complete_activity_list.append(activity_str)
if activity_percent != 1: incomplete_activity_list.append(activity_str)
old_activities_history = load_activities_history()
old_activities_history.append([current_date, complete_activity_list, incomplete_activity_list])
write_activities_history(old_activities_history)
clear_screen()
print_header()
if completed_day == False: current_days_perfect = 0; total_days_imperfect += 1; print_medium_spacer(); print("Day quit before completion, streak reset to zero."); print_medium_spacer()
if completed_day == True: print_medium_spacer(); print("Day completed! Current streak increased to", current_days_perfect, ". Max streak:", max_days_perfect); print_medium_spacer()
write_profile()
print('Lifetime Stats:')
print_medium_spacer()
print(get_profile_stats_string())
print_medium_spacer()
print_paragraph_whitespace()
state = "menu"
def delete_activity():
global activities_list
print_activities()
activity_to_delete = int(input("# of activity to delete: ")) - 1
print('Deleting Activity #', str(activity_to_delete + 1), '\n')
activities_list = ast.literal_eval(activities_list)
activities_list = list(activities_list)
activities_list.pop(activity_to_delete)
#activities_list = dict(activities_list)
write_activities_list(activities_list)
print('')
print_activities()
def get_activities_list():
global activities_list
activities_txt = open("activities.txt", "r")
activities_list = activities_txt.read()
def print_activities_history():
clear_screen()
print_header()
activities_history_list = load_activities_history()
for activity in activities_history_list:
print_medium_spacer()
print(activity[0])
print_medium_spacer()
print('Completed Activities:', len(activity[1]))
print_medium_spacer()
for activity_completed in activity[1]:
print(activity_completed)
print('')
print('Incomplete Activities:', len(activity[2]))
print_medium_spacer()
for activity_incomplete in activity[2]:
print(activity_incomplete)
print_medium_spacer()
print_paragraph_whitespace()
def print_activities():
global activities_list
clear_screen()
print_header()
get_activities_list()
print_task_stats()
print_medium_spacer()
i = 0
for activity in ast.literal_eval(activities_list):
i += 1
print('{:2.0f}'.format(i), activity['act_name'], '-', activity['act_desc'], activity['act_freq'], 'days a week', activity['act_amnt_min'], 'to', activity['act_amnt_max'], activity['act_unit'])
print_medium_spacer()
print_paragraph_whitespace()
def print_help():
clear_screen()
print_header()
print_medium_spacer()
print('Information:')
print_medium_spacer()
print('NEET MODE is a tool to semi-automate the this and the that of every day minutia. The user adds activities, adds info such as the maximum amount the activity should occur, the minimum amount the activity should occur, and the average frequency of the activity per week. The user can edit the information or delete any activity through the main menu options. After activities are added, the user can generate a list of activities through the main menu.')
print_medium_spacer()
print('The list of activities are generated on a day to day basis, where an activity being chosen for the day has a user directed X/7 chance of being displayed for the day, with no bearing on if the days prior had that task.')
print('This method of list generation means that even if a specific activity has a 1 in 7 chance of happening every day, it can happen two or three or four etc days in a row, but over time by virtue of randomness it will happen 1 out of 7 times per list generation.')
print_medium_spacer()
print_paragraph_whitespace()
def print_task_stats():
global activities_list
print(len(ast.literal_eval(activities_list)), 'Total Activities')
def menu_loop():
return input("Activities: 'g'enerate, 'l'oad (restore), 'v'iew all, 'e'dit, 'd'elete, 'a'dd, 'h'istory, q'uit: ")
def check_file(file_name, file_create_default):
try :
file = open(file_name)
except IOError:
file = open(file_name, 'w+')
file.write(file_create_default)
file.close()
check_file('current_activities.txt', '[]')
check_file('activities.txt', '[]')
check_file('activities_history.txt', '[]')
check_file('profile_stats.txt', '[1,1,1,1,1,1,100]')
load_profile()
while state == "menu":
get_activities_list()
print_header()
print(choice)
print_profile_stats()
print_task_stats()
print_medium_spacer()
if menu_input != '': print_medium_spacer()
if menu_input == "v": print_activities()
elif menu_input == "e": edit_activity()
elif menu_input == "g": generate_activities()
elif menu_input == "l": load_current_activities()
elif menu_input == "d": delete_activity()
elif menu_input == "a": add_activity()
elif menu_input == "h": print_activities_history()
elif menu_input == "help": print_help()
elif menu_input == "q": state = "quit"; break
if menu_input != '': print_medium_spacer()
if state == "menu": menu_input = menu_loop()
choice = 'Main Menu ' + str(randint(6, 93))
if menu_input == "v": choice = 'Activities'
elif menu_input == "e": choice = 'Edit Activity'
elif menu_input == "g": choice = 'Generated Activity List'
elif menu_input == "l": choice = 'Loaded Activity List'
elif menu_input == "d": choice = 'Delete Activity'
elif menu_input == "a": choice = 'Add Activity'
elif menu_input == "h": choice = 'History'
elif menu_input == "help": choice = 'Help'
if state == "quit":
clear_screen()
print_header()
print_paragraph_whitespace()
print(ascii_goodbye)
print_paragraph_whitespace()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment