Skip to content

Commit

Permalink
Merge pull request #140 from ECN/Bugfix-Webmaster-Queue
Browse files Browse the repository at this point in the history
Bugfix webmaster queue
  • Loading branch information
campb303 authored Feb 1, 2021
2 parents 7925d9a + 98843ef commit acaf76c
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions api/ECNQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def __parseHeaders(self) -> list:
# Example:
# [ce] QTime-Updated-By: campb303 becomes
# QTime-Updated-By: campb303
queuePrefixPattern = re.compile("\[.*\] {1}")
queuePrefixPattern = re.compile(r"\[.*?\] {1}")
for lineNumber in range(self.__getHeaderBoundary()):
line = self.__rawItem[lineNumber]
lineHasQueuePrefix = queuePrefixPattern.match(line)
Expand Down Expand Up @@ -263,6 +263,12 @@ def __parseSections(self) -> list:
for assignment in assignementLsit:
sections.append(assignment)

# Checks for empty content within an item and returns and
if contentEnd <= contentStart:
blankInitialMessage = self.__initialMessageParsing([""])
sections.append(blankInitialMessage)
return sections

# Checks for Directory Identifiers
if self.__rawItem[contentStart] == "\n" and self.__rawItem[contentStart + 1].startswith("\t"):

Expand Down Expand Up @@ -915,6 +921,10 @@ def __userReplyParsing(self, replyContent: list, lineNumber: int) -> dict:
if line == "\n":
newLineCounter = newLineCounter + 1

if newLineCounter == 2 and "datetime" not in replyFromInfo.keys():
errorMessage = "Expected \"Date: [datetime]\" in the header info"
return self.__errorParsing(line, lineNumber + lineNum + 1, errorMessage)

elif line == "===============================================\n":
endingDelimiterCount = endingDelimiterCount + 1

Expand Down Expand Up @@ -1190,7 +1200,19 @@ def __getUserAlias(self) -> str:
Returns:
str: User's Career Account alias if present or empty string
"""
emailUser, emailDomain = self.userEmail.split("@")


try:
emailUser, emailDomain = self.userEmail.split("@")

# Returns an error parse if the self.useremail doesn't contain exactally one "@" symbol
except ValueError:
# Parses through the self.headers list to find the "From" header and its line number
for lineNum, header in enumerate(self.headers):
if header["type"] == "From":
headerString = header["type"] + ": " + header["content"]
return self.__errorParsing(headerString, lineNum + 1, "Expected valid email Address")

return emailUser if emailDomain.endswith("purdue.edu") else ""

def __getFormattedDate(self, date: str) -> str:
Expand Down

0 comments on commit acaf76c

Please sign in to comment.