Question: LARGE PYTHON SCRIPT In a file called todo, write a python program to maintain a to do list with descriptions and due dates. This program
LARGE PYTHON SCRIPT In a file called todo, write a python program to maintain a to do list with descriptions and due dates. This program has several use cases. The user should be able to add tasks, search for tasks, and delete tasks. Tasks should be stored in a text file between runs in order to persist the data. todo has a similar structure to git, in that it takes a "command" argument as the first argument, followed by additional arguments or options based on the provided command. If no command is provided, print a short usage message like you see in the synopsis section of almost any man page (try git, cp, or rm for examples). Commands can be "add", "search", or "delete". If a command is unsuccessful for any reason (arguments incorrect, no matches to the search, no deletable items), a non-zero status code should be returned. Add The add command requires two arguments, the description and the due date of the task. If the arguments are not provided, or the date is not in MM/DD/YYYY, print a reasonable error message and quit. I recommend using the datetime package (https://docs.python.org/2/library/datetime.html) to validate that the dates are in the correct format. An example of a successful add is: ./todo add 'This is my description of my first task' 8/25/2017 Search The search command requires one argument and has two optional flags. search should print the entire description and due date of ALL matching tasks. If no options are given, search looks to see if the text provided is contained anywhere in the description. An example of a successful search is (> used to show program output): ./todo search 'task' > 8/25/17 -> This is my description of my first task > 8/26/18 -> Finish tasks all day The search command supports python style regular expressions by providing the -r flag. Note, python regular expressions are different from bash. Let python handle the regular expression parsing for you using the re package (https://docs.python.org/2/library/re.html) Please note, you have to quote the argument or bash will try to interpret it as filenames. An example of a successful search -r is: ./todo search -r '.*task\b.*' > 8/25/17 -> This is my description of my first task The search command supports searching by upcoming due date by providing the -d flag and a required numeric argument. The argument is the number of days forward to look for upcoming deadlines. Make sure to sort the output by due date. If todays date is 8/29/2017, and the user provides a 5, tasks for 8/29-9/3 should be printed. You will likely want to use the datetime package (https://docs.python.org/2/library/datetime.html) to do these computations and comparisons. An example of a successful search -d is: ./todo search -d 5 > 8/29/17 -> foo > 9/2/17 -> bar > 9/3/17 -> baz Delete The delete command requires two arguments, the description and the due date of the task. It searches for and removes ALL tasks with exactly that description and due date. An example of a successful delete is: ./todo delete 'This is my description of my first task' 8/25/2017
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
