-
Notifications
You must be signed in to change notification settings - Fork 0
Implement section parsing for item body. #2
Comments
The directory information is only present if the Trouble Report form was used to submit the item. |
@benf Useful information! I'll update my original post to add that logic. |
The JSON spec for this has been updated both inline and in this file. |
The current implementation is good enough for tomorrow's presentation but, moving forward, the delimiter information and newlines before/after the content should be removed from the content entry in the dictionary. Edit {
"type": "edit",
"by": "remender",
"datetime": "2020-03-11T09:42:52",
"content": [
"*** Edited by: remender at: 03/11/20 09:42:52 ***\n",
"\n",
"ST: 88QVQC2\n",
"\n",
"\n",
"\n"
]
}, This should be: {
"type": "edit",
"by": "remender",
"datetime": "2020-03-11T09:42:52",
"content": [
"ST: 88QVQC2\n",
]
}, Status {
"type": "status",
"by": "remender",
"datetime": "2020-03-11T09:26:19",
"content": [
"*** Status updated by: remender at: 3/11/2020 09:26:19 ***\n",
"waiting for reply\n",
"\n"
]
}, This should be: {
"type": "status",
"by": "remender",
"datetime": "2020-03-11T09:26:19",
"content": [
"waiting for reply\n"
]
}, Status Reply from ECN {
"type": "replyToUser",
"by": "remender",
"datetime": "2020-03-11T09:25:59",
"content": [
"*** Replied by: remender at: 03/11/20 09:25:59 ***\n",
"\n",
"Hi Yen-Fang,\n",
"\n",
"We can look into getting a quote for a replacement battery. Could you send us the Service Tag of the system?\n",
"\n",
"Josh Remender\n",
"ECN\n",
"\n"
]
}, This should be: {
"type": "replyToUser",
"by": "remender",
"datetime": "2020-03-11T09:25:59",
"content": [
"Hi Yen-Fang,\n",
"\n",
"We can look into getting a quote for a replacement battery. Could you send us the Service Tag of the system?\n",
"\n",
"Josh Remender\n",
"ECN\n",
]
}, Reply from User {
"type": "replyFromUser",
"datetime": "2020-03-11T13:39:02+0000",
"subject": "Re: Lab laptop swollen battery ",
"userName": "Yen-Fang Su",
"userEmail": "su177@purdue.edu",
"content": [
"=== Additional information supplied by user ===\n",
"\n",
"Subject: Re: Lab laptop swollen battery \n",
"From: Yen-Fang Su <su177@purdue.edu>\n",
"Date: Wed, 11 Mar 2020 13:39:02 +0000\n",
"X-ECN-Queue-Original-Path: /home/pier/e/queue/Attachments/inbox/2020-03-11/111-original.txt\n",
"X-ECN-Queue-Original-URL: https://engineering.purdue.edu/webqueue/Attachments/inbox/2020-03-11/111-original.txt\n",
"X-ECN-Queue-Attachment-1-URL: https://engineering.purdue.edu/webqueue/Attachments/inbox/2020-03-11/111-attachment-1.jpg\n",
"X-ECN-Queue-Attachment-1-Path: /home/pier/e/queue/Attachments/inbox/2020-03-11/111-attachment-1.jpg\n",
"\n",
"Hi Josh,\n",
"\n",
"Service tag:\n",
"\n",
"\n",
"===============================================\n",
"\n"
],
"ccRecipients": [
]
} This should be: {
"type": "replyFromUser",
"datetime": "2020-03-11T13:39:02+0000",
"subject": "Re: Lab laptop swollen battery ",
"userName": "Yen-Fang Su",
"userEmail": "su177@purdue.edu",
"content": [
"Hi Josh,\n",
"\n",
"Service tag:\n",
],
"ccRecipients": [
]
}, |
ECNQueue dedicates a dictionary to the Directory section of an Item, with keys that are parsed directly from the directory information within an item. Instead of this dictionary format:
The script will now dedicate a key to each delimiter in content, so the output reflects this structure:
Keys are not predetermined however, so any key, with the exception of "Name" can be included or excluded which will not affect the functionality of the directory section parsing. Currently, the script parses through raw directory information that looks like this:
The script will strip any leading and trailing white space (which includes tabs, spaces and newlines), directly from each line, and create a key value pair by splitting each into two substrings based on the location of the colon in each delimiter, effectively making a key, value pair which is then added to the directory Information dictionary as seen in the current json output above. |
def __getFormattedMessageContent(self, messageContent: list) -> list: This helper function was created within the |
Error parsing is detailed in #58 and now merges with this. All parsing dicussion should continue in this thread. |
Section Parsing Definitions
Introduction
The body of an item is made up of seven distinct actions Below are descriptions of each action, its purpose, behavior, metadata and delimiters.
Directory Information
Information about the user such as alias, phone number and office location. This only appears once right after the headers and right before the initial message. This only occurs if the item is submitted through the Trouble Reporting page.
Fields
type
directory_information
Name
Login
Computer
Location
Email
Phone
Office
UNIX Dir
Zero Dir
User ECNDB
Host ECNDB
Subject
Delimiters
\n\t
.Plain Text Example
Parsed Example
Initial Message
The body of the email the item originated from. This usually appears directly after the headers unless directory information is present.
Fields
type
initial_message
datetime
from_name
from_email
to
cc
subject
content
Delimiters
Plain Text Example
Parsed Example
Edit
Information added by someone at ECN, usually for internal use and/or communication. This can occur anywhere in the item after the initial message.
Fields
type
edit
datetime
by
content
Delimiters
*** Edited
Plain Text Example
Parsed Example
Status
A short message about the progress of the item. This can occur anywhere in the item after the initial message.
Fields
type
status
datetime
by
content
Delimiters
*** Status
Plain Text Example
Parsed Example
Assignment
Assigning the item to someone. This does not occur in the body of the item. It it tracked in the headers using three different entries:
Assigned-To-Updated-By
: the career account alias of the person who updated the assignmentAssigned-To-Updated-Time
: the time the assignment was updatedAssigned-To
: the career account alias of the person the item was assigned toFields
type
assignment
datetime
by
to
Delimiters
N/A
Plain Text Example
Parsed Example
Reply To User
A message from ECN to the user and/or related parties. This can occur anywhere in the item after the initial message.
Fields
type
reply_to_user
datetime
by
content
Delimiters
*** Replied
Plain Text Example
Parsed Example
Reply from User
A message from the user and/or related parties. This is only found after two or more items have been merged together. This can occur anywhere in the item after the initial message.
Fields
type
reply_from_user
datetime
from_name
from_email
cc
headers
subject
content
Delimiters:
===
====
Plain Text Example
Parsed Example
Parse Error
An error caused by a malformed delimiter or nested delimiters. Parse errors only occur if a delimiter is incorrectly formatted or a delimiter is nested in a reply-from-user.
Fields
type
parse_error
datetime
file_path
expected
got
line_num
Plain Text Example
Parsed Example
The text was updated successfully, but these errors were encountered: