summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--goatNote.py58
1 files changed, 52 insertions, 6 deletions
diff --git a/goatNote.py b/goatNote.py
index fb419b9..ff76bd6 100644
--- a/goatNote.py
+++ b/goatNote.py
@@ -9,19 +9,65 @@ class tokenTypes (Enum):
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
-# TODO keep the stuff in order when it lists 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*"
- heading = re.findall(headingRe, file)
- print(heading)
- bulletPoint = re.findall(bulletPointRe, file)
- print(bulletPoint)
+ 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
-tokenize("""
+values, types = tokenize("""
*heading* [1004.23.23] {TO.DO}
- hi
- hey