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
|
from enum import Enum
import re
# Assigning numbers to types of data
class tokenTypes (Enum):
HEADING = 1
DATE = 2
TODO = 3
BULLETPOINT = 4
class date:
day = 0
month = 0
year = 0
def __init__(self, dateString: str):
dateString = dateString.split(".")
self.year = int(dateString[0])
self.month = int(dateString[1])
self.day = int(dateString[2])
# Tokenizing
# TODO ADD SPACES TO HEADING TODO
def tokenize(file: str):
headingRe = r"\s*\*\s*([A-z0-9]+)\s*\*\s*\[(\d\d\d\d[.]\d\d[.]\d\d)\]\s*{(TO[.]DO|DONE)}\s*"
bulletPointRe = r"-\s*([A-z0-9]+)\s*"
unprocessed = []
end = False
while not end:
heading = re.match(headingRe, file)
bulletPoint = re.match(bulletPointRe, file)
if heading != None:
unprocessed.append(heading.group())
file = file[heading.span()[1]:]
elif bulletPoint != None:
unprocessed.append(bulletPoint.group())
file = file[bulletPoint.span()[1]:]
else:
end = True
values = []
types = []
for i in unprocessed:
heading = re.findall(headingRe, i)
bulletPoint = re.findall(bulletPointRe, i)
if heading != []:
heading = heading[0]
values.append(heading[0])
types.append(tokenTypes.HEADING)
values.append(date(heading[1]))
types.append(tokenTypes.DATE)
if heading[2] == "TO.DO":
values.append(True)
else:
values.append(False)
types.append(tokenTypes.TODO)
elif bulletPoint != []:
values.append(bulletPoint[0])
types.append(tokenTypes.BULLETPOINT)
return values, types
values, types = tokenize("""
*heading* [1004.23.23] {TO.DO}
- hi
- hey
*heading* [1004.23.23] {TO.DO}
- hi
- hey
""")
# Drop user into a shell
print("enter one of the following commands: list, toggle, change date, view, formatting help, or type close to exit program")
line = input(": ")
while line != "close":
if line == "list":
print("you said to list :)")
elif line == "toggle":
print("You said toggle :(")
elif line == "change date":
print("CHANGE DATEEE")
elif line == "view":
print("look at me (view)")
elif line == "formatting help":
print("you need help? loser.")
else:
print("Invalid command :(")
line = input(": ")
print("byee(closing file)")
|