Skip to content

Staging #81

Merged
merged 2 commits into from
Oct 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions api/ECNQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
currentFileDirectory = os.path.dirname(currentFilePath)
currentFileDirectoryParent = os.path.dirname(currentFileDirectory)
queueDirectory = os.path.join(currentFileDirectoryParent, "q-snapshot")
#queueDirectory = "/usr/site/uds/qcopy/11"

# Queues to not load in getQueues()
queuesToIgnore = ["archives", "drafts", "inbox"]
Expand Down Expand Up @@ -228,7 +229,12 @@ def __parseSections(self) -> list:
line = self.__rawItem[lineNumber]

# Looks for a starting delimiter and explicity excludes the reply-from-user ending delimiter
if line.startswith("***") or line.startswith("===") and not line.startswith("===="):
if (line.startswith("*** Edited by: ") or
line.startswith("*** Replied by: ") or
line.startswith("*** Status updated by: ") or
line == "=== Additional information supplied by user ===\n" and not
line == "===============================================\n"
):

# Sets the delimiter type based on the pattern within the delimiters list
for delimiter in delimiters:
Expand Down Expand Up @@ -585,7 +591,7 @@ def __editParsing(self, content: list, lineNum: int) -> dict:
editInfo = {}

for count, line in enumerate(content):
if line.startswith("===="):
if line == "===============================================\n" :
errorMessage = "Reply-from-user ending delimter encountered without Reply-from-user starting delimter"
return self.__errorParsing(line, lineNum + count + 1, errorMessage)

Expand Down Expand Up @@ -645,7 +651,7 @@ def __replyToParsing(self, content: list, lineNum: int) -> dict:
delimiterLine = content[0]

for count, line in enumerate(content):
if line.startswith("===="):
if line == "===============================================\n":
errorMessage = "Reply-from-user ending delimter encountered without Reply-from-user starting delimter"
return self.__errorParsing(line, lineNum + count + 1, errorMessage)

Expand Down Expand Up @@ -695,7 +701,7 @@ def __statusParsing(self, content: list, lineNum: int) -> dict:
delimiterLine = content[0]

for count, line in enumerate(content):
if line.startswith("===="):
if line == "===============================================\n":
errorMessage = "Reply-from-user ending delimter encountered without Reply-from-user starting delimter"
return self.__errorParsing(line, lineNum + count + 1, errorMessage)

Expand Down Expand Up @@ -793,15 +799,24 @@ def __userReplyParsing(self, replyContent: list, lineNumber: int) -> dict:
)
except:
lenReplyFromHeaders = len(replyFromHeaders)

replyFromHeaders[lenReplyFromHeaders - 1]["content"] = replyFromHeaders[lenReplyFromHeaders - 1]["content"] + " " + line
if lenReplyFromHeaders == 0:
errorMessage = ("Expected reply-from-user header information:\n" +
"=== Additional information supplied by user ===\n" +
"\n" +
"[Header Type]: [Header Value]\n" +
"\n"
)
return self.__errorParsing(line, lineNumber + lineNum + 1, errorMessage)

else:
replyFromHeaders[lenReplyFromHeaders - 1]["content"] = replyFromHeaders[lenReplyFromHeaders - 1]["content"] + " " + line

linesToRemove.append(lineNum)
#Checks for a newline and breaks for loop on second occurance of a newline
if line == "\n":
newLineCounter = newLineCounter + 1

elif line.startswith("===="):
elif line == "===============================================\n":
endingDelimiterCount = endingDelimiterCount + 1

elif line.startswith("From: ") and newLineCounter == 1:
Expand Down Expand Up @@ -880,7 +895,13 @@ def __getFormattedSectionContent(self, sectionContent: list) -> list:
"""
# Continually removes the first line of sectionContent if it is a newline or delimiter in each iteration
while len(sectionContent) > 1:
if sectionContent[0] == "\n" or sectionContent[0].startswith("***") or sectionContent[0].startswith("===") :
if (sectionContent[0] == "\n" or
sectionContent[0].startswith("*** Edited by: ") or
sectionContent[0].startswith("*** Replied by: ") or
sectionContent[0].startswith("*** Status updated by: ") or
sectionContent[0] == "=== Additional information supplied by user ===\n" or
sectionContent[0] == "===============================================\n"
):
sectionContent.pop(0)
else:
# Breaks the loop if the first line isn't a newline or delimiter
Expand All @@ -891,7 +912,9 @@ def __getFormattedSectionContent(self, sectionContent: list) -> list:
# Initializes the Length of sectionContent each iteration of the loop
sectionContentLength = len(sectionContent)

if sectionContent[sectionContentLength -1] == "\n" or sectionContent[sectionContentLength -1].startswith("===="):
if (sectionContent[sectionContentLength -1] == "\n" or
sectionContent[sectionContentLength -1] == "===============================================\n"
):
sectionContent.pop(sectionContentLength - 1)
else:
# Breaks the loop if the last line isn't a newline or delimiter
Expand Down