-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
142 lines (111 loc) · 3.45 KB
/
app.py
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
from src.Database.DatabaseHandler import DatabaseHandler
from src.Datastructures.StandupEvent import StandupEvent
from src.Standup.Standup import Standup
from src.Standup.GuiPrompt import GuiPrompt
import pyperclip
from dateutil.parser import parse
from datetime import datetime as dt
gui = GuiPrompt()
db = DatabaseHandler()
stnd = Standup()
save_file: str = "standups.txt"
read_file: str = "standups.txt"
add_task: str = "-"
add_standup_string: str = "+"
copy_current_standup_string: str = "c"
save_to_file_string: str = "s"
read_from_file_string: str = "r"
prefix = add_standup_string
current_message = "Welcome!"
options = {
# "Add Task": add_task,
"Add stand-up": add_standup_string,
"Copy current stand-up": copy_current_standup_string,
"Save to file": save_to_file_string,
"Read from file": read_from_file_string,
}
def add_standup():
prompt = "Date: "
try:
date = parse(input(prompt))
except Exception as e:
print(e)
date = dt.now()
print("Fallback = Default date.")
pass
prompt = "Today: "
desc = input(prompt)
if len(desc) < 1:
desc = None
prompt = "Blockers: "
blocker = input(prompt)
if len(blocker) < 1:
blocker = None
s = StandupEvent(
date=date,
description=desc,
blocker=blocker,
)
db.add_standup_event(s)
def copy_current_standup():
standups: [StandupEvent] = db.get_standups(count=2)
if len(standups) < 1:
gui.set_message("You need a standup.")
return
if len(standups) < 2:
standups.append(StandupEvent())
pyperclip.copy(stnd.generate_standup_status(standups[1],standups[0]))
gui.set_message("Copied to clipboard!")
def save_to_file():
with open(save_file, "w+") as out_file:
for s in db.get_standups(count=-1):
out_file.write(s.string())
out_file.write("\n")
gui.set_message("Saved to file.")
def read_from_file():
with open(read_file, "r+") as in_file:
count = 0
date = ''
yesterday = ''
today = ''
blocker = ''
for line in in_file.readlines():
cleaned_string = line.replace("ID: ", "")
cleaned_string = cleaned_string.replace("DATE: ", "")
cleaned_string = cleaned_string.replace("DESCRIPTION: ", "")
cleaned_string = cleaned_string.replace("BLOCKER: ", "")
cleaned_string = cleaned_string.replace("\n", "")
if count == 0:
standup_id = cleaned_string
if count == 1:
date = cleaned_string
if count == 2:
today = cleaned_string
if count == 3:
blocker = cleaned_string
if count == 4:
s = StandupEvent(
date = parse(date),
description=today,
blocker=blocker
)
db.add_standup_event(s)
count = 0
continue
count = count + 1
gui.set_message("Read from file.")
while (True):
gui.clear()
gui.print_menu(options)
ans = input("-")
if ans == add_standup_string:
add_standup()
continue
if ans == copy_current_standup_string:
copy_current_standup()
continue
if ans == save_to_file_string:
save_to_file()
continue
if ans == read_from_file_string:
read_from_file()