forked from ZG34/RubiconReminders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rubicon_reminders_cli.py
70 lines (63 loc) · 2.4 KB
/
rubicon_reminders_cli.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
# the comments in this file were made while learning, as reminders
# to RUN APP IN CMD PROMPT: cd to this directory, or place in default CMD directory:
# then run 'python rubicon_reminders_cli.py'
from os import listdir
from datetime import datetime
# this assigns dt variable as date + timestamp
dt = (datetime.now())
# TODO numerate note items per entry
# open existing or create a new file prompt:
p1 = input("(V)iew or (N)ew [V/N]: ").upper()
if p1 == "V":
# this views file directory of existing notes if first input is (view)
for file in listdir():
if file.endswith(".txt"):
print(file)
# below opens existing file, allows multiple note lines, and dates it when finished with session.
old_file = (input("which file would you like to open: "))
hdl = open(old_file + ".txt", "r+") # using r+ by default places text at beginning, overwriting.
for line in hdl: # as long as you first READ the file, then r+ becomes APPEND TO END.
print(line.strip())
of_note = input("Add Note: ")
if of_note == "done": # FIXME add accept on any 'done' check for upper and lowercase
# specifies notes were reviewed if first note entry is "done"
hdl.write(" REVIEWED: ")
hdl.write(str(dt))
# if first entered note is not 'done', continue asking for more notes until entry == 'done'
else:
hdl.write('\n')
hdl.write(of_note)
hdl.write('\n')
while of_note != "done":
of_note = input("Add more notes: ")
while of_note != "done":
hdl.write(of_note)
hdl.write('\n')
else:
hdl.write("SESSION END: ")
hdl.write(str(dt))
hdl.write('\n')
hdl.close()
# below is the block for generating and noting in a new file, if line 15 == 'N'
elif p1 == "N":
new_file = input("new file name: ")
hdl = open(new_file, "a")
nf_note = input("Add Note: ")
if nf_note == "done":
print("finished")
else:
hdl.write(nf_note)
hdl.write('\n')
while nf_note != "done":
nf_note = input("Add more notes: ")
while nf_note != "done":
hdl.write(nf_note)
hdl.write('\n')
break
else:
hdl.write("SESSION END: ")
hdl.write(str(dt))
hdl.write('\n')
hdl.close()
else:
print("Error: please enter V or N")