Skip to content

Commit

Permalink
Partial functionality added for parsing reply from user section
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Daniel Bennett committed Sep 15, 2020
1 parent dea72bd commit 58381c5
Showing 1 changed file with 67 additions and 8 deletions.
75 changes: 67 additions & 8 deletions api/ECNQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ def __parseSections(self) -> list:
"time": formattedTime,
"content": sectionContent,}
)

sectionContent.remove(line)

elif sectionType == "replyToUser":
formattedDate = ""
Expand Down Expand Up @@ -326,19 +328,76 @@ def __parseSections(self) -> list:
"time": formattedTime,
"content": sectionContent}
)
#sectionContent.remove(line)

#elif sectionType == "":
elif sectionType == "replyFromUser":

#replyMetaDataDelimiters = ["Subject: ", "From: ", "Date: "]

elif sectionType == "":
#elif sectionType == "replyFromUser":
formattedDate = ""
formattedTime = ""
repliedBy = ""

repliedByName = ""
repliedByEmail = ""
subject = ""
ccRecipientsList = []
ccRecipientDict = {}

"""
ccRecipientDict Format:
ccRecipientDict = {
"Name": Name
"Email": Email
}
"""

lineNum = 0
linesToBeDeleted = [0]

for items in sectionContent:
if items.startswith("Subject: "):
subject = (re.search("(?<=Subject: )(.*)", items)).group()
linesToBeDeleted.append(lineNum)

elif items.startswith("From: "):
repliedByEmail = (re.search("(?<=From: )(.*)(?= <)", items)).group()
repliedByName = (re.search("(?<= <)(.*)(?=>)", items)).group()
linesToBeDeleted.append(lineNum)

elif items.startswith("Date: "):
dateStr = (re.search("(?<=Date: )(.*)", items)).group()

try:
dateObject = parse(dateStr)
formattedDate = dateObject.strftime("%Y-%m-%dT%H:%M:%S%z")
formattedTime = dateObject.strftime("%H:%M:%S%z")
linesToBeDeleted.append(lineNum)
except:
formattedDate = "invalid"
formattedTime = "Invalid"

elif items.startswith("Cc: "):
ccString = (re.search("(?<=Cc: )(.*)", items)).group()
#######################################################################################

lineNum = lineNum + 1

for lineNumbers in sorted(linesToBeDeleted, reverse=True):
sectionContent.pop(lineNumbers)
#parses for the author of the status change, which is located between the "*** Status updated by: " and " at:" substrings
updatedBy = (re.search("(?<=\*{3} Status updated by: )(.*)(?= at:)", line)).group()
#updatedBy = (re.search("(?<=\*{3} Status updated by: )(.*)(?= at:)", line)).group()

#parses for the date and time of the status change, which is located between the " at: " and "***\n" substrings
dateTimeString = (re.search("(?<= at: )(.*)(?= \*\*\*\n)", line)).group()

#dateTimeString = (re.search("(?<= at: )(.*)(?= \*\*\*\n)", line)).group()
sections.append(
{"type": sectionType,
"date": formattedDate,
"time": formattedTime,
"subject": subject,
"userName": repliedByName,
"userEmail": repliedByEmail,
"content": sectionContent}
)

else:
sections.append(
Expand Down Expand Up @@ -522,5 +581,5 @@ def getQueues() -> list:
return queues

if __name__ == "__main__":
item = Item("ce", 11)
item = Item("ce", 100)
print()

0 comments on commit 58381c5

Please sign in to comment.