diff --git a/api/ECNQueue.py b/api/ECNQueue.py index 6535ad8..da2cf33 100644 --- a/api/ECNQueue.py +++ b/api/ECNQueue.py @@ -242,14 +242,49 @@ def __parseSections(self) -> list: # Adds the contents of the line to the directory info directoryInfo.append(lineContents) + # allows to move to the next iteration of the parent for loop, no need to continue parsing directory delimiters break # Increment the line counter by after each line lineCounter = lineCounter + 1 + # Parses the initial message to remove directory information for lineNumber in sorted(directoryLinesToRemove, reverse=True): + + # Remove the directory line from the intital message initialMessageContent.pop(lineNumber) + + # Removes unecessary newlines from the begining and the end of the initial message + newLinebegining = True + newLineEnd = True + + while newLinebegining or newLineEnd: + # Initializes the Length of Message content each iteration of the loop + initialmessagecontentLength = len(initialMessageContent) + + # Checks if the last line is a newline + if initialMessageContent[initialmessagecontentLength -1] == "\n": + + # Deletes the last line if it is a newline + initialMessageContent.pop(initialmessagecontentLength - 1) + + # If the previous condition failed, then set the new line end to False if it isn't false already + elif newLineEnd == True: + + newLineEnd = False + + # Checks if the first line in message content is a newline + if initialMessageContent[0] == "\n": + + # Removes the first line in message content if it is a newline + initialMessageContent.pop(0) + + # If the previous condition failed, then set the new line begining to False if it isn't false already + elif newLinebegining == True: + + newLinebegining = False + # Appends Directory Information into the sections array sections.append( {"type": "directoryInformation", @@ -767,5 +802,4 @@ def getQueues() -> list: if isDirectory and isValid: queues.append(Queue(file)) - return queues - + return queues \ No newline at end of file