-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo_helper.py
More file actions
67 lines (59 loc) · 2.06 KB
/
todo_helper.py
File metadata and controls
67 lines (59 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from rich.panel import Panel
from rich import box
from rich.box import ROUNDED
from rich.console import Console
from rich.table import Table
from rich.traceback import install
from rich.align import Align
install(show_locals=True)
console = Console()
from rich.text import Text
import csv
def noData():
noDataText = Text("There are currently no tasks in your to-do list!\nAdd a task to get started!", justify="center")
noDataPanel = Panel(noDataText, style="#FFAE00", width=80, padding=(1, 1), title="To-Do List")
console.print(noDataPanel)
def parseTodo():
"""
Parses and displays todo data from the CSV file.
"""
try:
with open('root/documents/todo.csv', 'r', encoding='utf-8') as file:
# Using DictReader is great for this
reader = csv.DictReader(file)
tasks = list(reader)
if not tasks:
noData()
return
table = Table(title="Your To-Do list", box=box.ROUNDED)
table.add_column("Task Name", style="cyan", no_wrap=True)
table.add_column("Task Info", style="green")
table.add_column("Task Status", style="yellow")
statusStyles = {
'complete': "#26FF00",
'in progress': "#F0FF50",
'incomplete': "#FF0000"
}
for task in tasks:
status = task.get('status', 'incomplete').strip().lower()
style = statusStyles.get(status, 'white')
table.add_row(
task.get('taskName', 'N/A'),
task.get('taskInfo', ''),
f'[{style}]{task.get("status", "N/A").capitalize()}[/]'
)
bigBox = Panel(
Align.center(table),
title="[bold]To-Do App[/bold]",
width=80,
box=ROUNDED,
border_style="#00AEFF"
)
bigBox = Align.center(bigBox)
console.print(bigBox)
except FileNotFoundError:
# This will be hit if the file doesn't exist yet
noData()
def validated(userInput):
validInput = [1, 2, 3, 4]
return userInput in validInput