Skip to content

Instantly share code, notes, and snippets.

@Sisyphus67
Last active January 19, 2021 12:15
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Sisyphus67/f7f7487004dde37ab2ab053cb4c0e3ac to your computer and use it in GitHub Desktop.
Save Sisyphus67/f7f7487004dde37ab2ab053cb4c0e3ac to your computer and use it in GitHub Desktop.
This program outputs a csv file that can be used as a ToDoist template. The template is to create a study plan for a text book.
#!/usr/bin/python
"""
Copyright (C) 2016 Jeffrey S. McAnarney
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
import sys
from datetime import date, datetime
__author__ = 'sisyphus'
categories = "TYPE,CONTENT,PRIORITY,INDENT,AUTHOR,RESPONSIBLE,DATE,DATE_LANG,TIMEZONE"
print("Answer the questions about your study goals.\n")
book = raw_input("\nEnter the name of the book you are studying: ")
num_chapters = int(raw_input("Enter the number of chapters in the book to study: "))
days_per_chapter = int(raw_input("Enter number of days to study each chapter : "))
user = raw_input("Enter your Todoist User ID: ")
file_location = raw_input("Enter the name of the template you wish to create: ")
start = raw_input("Enter the day you wish to start studying [YYYY-MM-DD]: ")
end = raw_input("Enter the day to end studying [YYYY-MM-DD]: ")
lstStart, lstEnd = map(int, start.split('-')), map(int, end.split('-'))
dateStart = date(lstStart[0], lstStart[1], lstStart[2])
dateEnd = date(lstEnd[0], lstEnd[1], lstEnd[2])
days_to_study = (dateEnd - dateStart).days
if int(days_to_study) < (days_per_chapter * num_chapters):
print("Not enough time to study {} chapters for {} days each".format(num_chapters, days_per_chapter))
proceed = raw_input("Would you like to study each chapter for {} days or quit? [1 to proceed, 0 to quit]".format(
int(days_to_study / num_chapters)))
if proceed == 1:
days_per_chapter = int(days_to_study / num_chapters)
else:
sys.exit(-1)
with open(file_location, "w") as fout:
fout.write(categories + "\n")
initial = (dateStart - date.today()).days
fout.write(
"task,Start studying Chapter One of {0} @school,2,1,{1},,in {2} days,en,US/Central\n,,,,,,,,\n".format(book,
user,
initial))
for chapter in range(1, num_chapters):
due = (chapter * days_per_chapter) + initial
task1_str = "task,Study Chapter {0}: {3} @school,2,1,{2},,in {1} days,en,US/Central\n,,,,,,,,\n".format(chapter,
due,
user,
book)
subtask1_str = "task,Read Chapter {0} @school,1,2,{2},,in {1} days,en,US/Central\n,,,,,,,,\n".format(chapter,
due - 2,
user)
subtask2_str = "task,Annotate Chapter {0} @school,2,2,{2},,in {1} days,en,US/Central\n,,,,,,,,\n".format(
chapter, due - 1, user)
subtask3_str = "task,Skim Chapter {0} @school,2,2,{2},,in {1} days,en,US/Central\n,,,,,,,,\n".format(
chapter + 1, due + 1, user)
fout.write(task1_str)
fout.write(subtask1_str)
fout.write(subtask2_str)
if num_chapters != chapter:
fout.write(subtask3_str)
else:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment