diff --git a/api/ECNQueue.py b/api/ECNQueue.py index 8230d9f..ae6c424 100644 --- a/api/ECNQueue.py +++ b/api/ECNQueue.py @@ -526,7 +526,7 @@ def __initialMessageParsing(self, content: list) -> dict: initialMessageDictionary["subject"] = self.__getMostRecentHeaderByType("Subject") # Removes unecessary newlines from the begining and the end of the initial message - initialMessageDictionary["content"] = self.__getFormattedMessageContent(content) + initialMessageDictionary["content"] = self.__getFormattedSectionContent(content) return initialMessageDictionary @@ -566,7 +566,7 @@ def __editParsing(self, content: list, lineNum: int) -> dict: editInfo["datetime"] = self.__getFormattedDate(dateTimeString) # Remove the delimiter String and unecessary newlines - editInfo["content"] = self.__getFormattedMessageContent(content) + editInfo["content"] = self.__getFormattedSectionContent(content) return editInfo @@ -605,7 +605,7 @@ def __replyToParsing(self, content: list, lineNum: int) -> dict: # Formats date to UTC replyInfo["datetime"] = self.__getFormattedDate(dateTimeString) - replyInfo["content"] = self.__getFormattedMessageContent(content) + replyInfo["content"] = self.__getFormattedSectionContent(content) return replyInfo @@ -647,7 +647,7 @@ def __statusParsing(self, content: list, lineNum: int) -> dict: statusInfo["datetime"] = self.__getFormattedDate(dateTimeString) # Remove the delimiter String and unecessary newlines - statusInfo["content"] = self.__getFormattedMessageContent(content) + statusInfo["content"] = self.__getFormattedSectionContent(content) return statusInfo @@ -747,39 +747,52 @@ def __userReplyParsing(self, replyContent: list, lineNumber: int) -> dict: replyContent.pop(lineNum) # Strips any unnecessary newlines or any delimiters frm the message content - replyFromInfo["content"] = self.__getFormattedMessageContent(replyContent) + replyFromInfo["content"] = self.__getFormattedSectionContent(replyContent) replyFromInfo["headers"] = replyFromHeaders return replyFromInfo - def __getFormattedMessageContent(self, messageContent: list) -> list: + def __getFormattedSectionContent(self, sectionContent: list) -> list: """Returns a list with message content that is stripped of unnecessary newlines and begining delimiters + Example: + *** Edited by: mph at: 02/21/20 10:27:16 ***\n + \n + Still need to rename machines - but the networking issue now seems to \n + be resolved via another ticket.\n + \n + \n + \n + \n + \n + + Args: + sectionContent (list): The section content of a parsed section + Returns: - list: formattedMessageContent + list: the section content of a parsed section without any delimiters and unnecessary newlines """ - - # Continually removes the first line of messageContent if it is a newline or delimiter in each iteration - while len(messageContent) > 1: - if messageContent[0] == "\n" or messageContent[0].startswith("***") or messageContent[0].startswith("===") : - messageContent.pop(0) + # 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("===") : + sectionContent.pop(0) else: # Breaks the loop if the first line isn't a newline or delimiter break - # Continually removes the last line of messageContent if it is a newline or delimiter in each iteration - while len(messageContent) > 1: - # Initializes the Length of messageContent each iteration of the loop - messagecontentLength = len(messageContent) + # Continually removes the last line of sectionContent if it is a newline or delimiter in each iteration + while len(sectionContent) > 1: + # Initializes the Length of sectionContent each iteration of the loop + sectionContentLength = len(sectionContent) - if messageContent[messagecontentLength -1] == "\n" or messageContent[messagecontentLength -1].startswith("===="): - messageContent.pop(messagecontentLength - 1) + if sectionContent[sectionContentLength -1] == "\n" or sectionContent[sectionContentLength -1].startswith("===="): + sectionContent.pop(sectionContentLength - 1) else: # Breaks the loop if the last line isn't a newline or delimiter break - return messageContent + return sectionContent def __errorParsing(self, line: str, lineNum: int, expectedSyntax: str) -> dict: """Returns a dictionary with error parse information when a line is malformed