def parse_email(data, type=1): email_dict = {} if type == 1: email_base = data.get_children() email_dict.update({"server_id": email_base[0].text}) email_elements = email_base[1].get_children() for element in email_elements: if element.tag == "email:To": email_dict.update({"email_To": element.text}) elif element.tag == "email:Cc": email_dict.update({"email_Cc": element.text}) elif element.tag == "email:From": email_dict.update({"email_From": element.text}) elif element.tag == "email:Subject": email_dict.update({"email_Subject": element.text}) elif element.tag == "email:ReplyTo": email_dict.update({"email_ReplyTo": element.text}) elif element.tag == "email:DateReceived": email_dict.update({"email_DateReceived": element.text}) elif element.tag == "email:DisplayTo": email_dict.update({"email_DisplayTo": element.text}) elif element.tag == "email:ThreadTopic": email_dict.update({"email_ThreadTopic": element.text}) elif element.tag == "email:Importance": email_dict.update({"email_Importance": element.text}) elif element.tag == "email:Read": email_dict.update({"email_Read": element.text}) elif element.tag == "airsyncbase:Attachments": email_dict.update({ "airsyncbase_Attachments": airsyncbase_Attachments.parse(element) }) elif element.tag == "airsyncbase:Body": body = airsyncbase_Body() body.parse(element) email_dict.update({"airsyncbase_Body": body}) elif element.tag == "email:MessageClass": email_dict.update({"email_MessageClass": element.text}) elif element.tag == "email:InternetCPID": email_dict.update({"email_InternetCPID": element.text}) elif element.tag == "email:Flag": flag = email_Flag() flag.parse(element) email_dict.update({"email_Flag": flag}) elif element.tag == "airsyncbase:NativeBodyType": email_dict.update({"airsyncbase_NativeBodyType": element.text}) elif element.tag == "email:ContentClass": email_dict.update({"email_ContentClass": element.text}) elif element.tag == "email2:UmCallerId": email_dict.update({"email2_UmCalledId": element.text}) elif element.tag == "email2:UmUserNotes": email_dict.update({"email2_UmUserNotes": element.text}) elif element.tag == "email2:ConversationId": email_dict.update({"email2_ConversationId": element.text}) elif element.tag == "email2:ConversationIndex": email_dict.update({"email2_ConversationIndex": element.text}) elif element.tag == "email2:LastVerbExecuted": email_dict.update({"email2_LastVerbExecuted": element.text}) elif element.tag == "email2:LastVerbExecutedTime": email_dict.update( {"email2_LastVerbExecutedTime": element.text}) elif element.tag == "email2:ReceivedAsBcc": email_dict.update({"email2_ReceivedAsBcc": element.text}) elif element.tag == "email2:Sender": email_dict.update({"email2_Sender": element.text}) elif element.tag == "email:Categories": categories_list = [] categories = element.get_children() for category_element in categories: categories_list.append(category_element.text) email_dict.update({"email_Categories": categories_list}) elif element.tag == "airsyncbase:BodyPart": email_dict.update( {"airsyncbase_Body": airsyncbase_BodyPart.parse(element)}) elif element.tag == "email2:AccountId": email_dict.update({"email2_AccountId": element.text}) elif element.tag == "rm:RightsManagementLicense": continue return email_dict
def parse_email(data, type=1): email_dict = {} if type == 1: email_base = data.get_children() email_dict.update({"server_id" : email_base[0].text}) email_elements = email_base[1].get_children() for element in email_elements: if element.tag == "email:To": email_dict.update({ "email_To" : element.text }) elif element.tag == "email:Cc": email_dict.update({ "email_Cc" : element.text }) elif element.tag == "email:From": email_dict.update({ "email_From" : element.text }) elif element.tag == "email:Subject": email_dict.update({ "email_Subject" : element.text }) elif element.tag == "email:ReplyTo": email_dict.update({ "email_ReplyTo" : element.text }) elif element.tag == "email:DateReceived": email_dict.update({ "email_DateReceived" : element.text }) elif element.tag == "email:DisplayTo": email_dict.update({ "email_DisplayTo" : element.text }) elif element.tag == "email:ThreadTopic": email_dict.update({ "email_ThreadTopic" : element.text }) elif element.tag == "email:Importance": email_dict.update({ "email_Importance" : element.text }) elif element.tag == "email:Read": email_dict.update({ "email_Read" : element.text }) elif element.tag == "airsyncbase:Attachments": email_dict.update({ "airsyncbase_Attachments" : airsyncbase_Attachments.parse(element)}) elif element.tag == "airsyncbase:Body": body = airsyncbase_Body() body.parse(element) email_dict.update({ "airsyncbase_Body" : body }) elif element.tag == "email:MessageClass": email_dict.update({ "email_MessageClass" : element.text }) elif element.tag == "email:InternetCPID": email_dict.update({ "email_InternetCPID" : element.text }) elif element.tag == "email:Flag": flag = email_Flag() flag.parse(element) email_dict.update({ "email_Flag" : flag}) elif element.tag == "airsyncbase:NativeBodyType": email_dict.update({ "airsyncbase_NativeBodyType" : element.text }) elif element.tag == "email:ContentClass": email_dict.update({ "email_ContentClass" : element.text }) elif element.tag == "email2:UmCallerId": email_dict.update({ "email2_UmCalledId" : element.text }) elif element.tag == "email2:UmUserNotes": email_dict.update({ "email2_UmUserNotes" : element.text }) elif element.tag == "email2:ConversationId": email_dict.update({ "email2_ConversationId" : element.text }) elif element.tag == "email2:ConversationIndex": email_dict.update({ "email2_ConversationIndex" : element.text }) elif element.tag == "email2:LastVerbExecuted": email_dict.update({ "email2_LastVerbExecuted" : element.text }) elif element.tag == "email2:LastVerbExecutedTime": email_dict.update({ "email2_LastVerbExecutedTime" : element.text }) elif element.tag == "email2:ReceivedAsBcc": email_dict.update({ "email2_ReceivedAsBcc" : element.text }) elif element.tag == "email2:Sender": email_dict.update({ "email2_Sender" : element.text }) elif element.tag == "email:Categories": categories_list = [] categories = element.get_children() for category_element in categories: categories_list.append(category_element.text) email_dict.update({ "email_Categories" : categories_list }) elif element.tag == "airsyncbase:BodyPart": email_dict.update({ "airsyncbase_Body" : airsyncbase_BodyPart.parse(element)}) elif element.tag == "email2:AccountId": email_dict.update({ "email2_AccountId" : element.text }) elif element.tag == "rm:RightsManagementLicense": continue return email_dict
def parse(self, inwapxml_airsync_command): email_base = inwapxml_airsync_command.get_children() self.server_id = email_base[0].text email_elements = email_base[1].get_children() for element in email_elements: if element.tag == "email:To": self.email_To = element.text elif element.tag == "email:Cc": self.email_Cc = element.text elif element.tag == "email:From": self.email_From = element.text elif element.tag == "email:Subject": self.email_Subject = element.text elif element.tag == "email:ReplyTo": self.email_ReplyTo = element.text elif element.tag == "email:DateReceived": self.email_DateReceived = element.text elif element.tag == "email:DisplayTo": self.email_DisplayTo = element.text elif element.tag == "email:ThreadTopic": self.email_TreadTopic = element.text elif element.tag == "email:Importance": self.email_Importance = element.text elif element.tag == "email:Read": self.email_Read = element.text elif element.tag == "airsyncbase:Attachments": self.airsyncbase_Attachments = airsyncbase_Attachments.parse( element) elif element.tag == "airsyncbase:Body": body = airsyncbase_Body() body.parse(element) self.airsyncbase_Body = body elif element.tag == "email:MessageClass": self.email_MessageClass = element.text elif element.tag == "email:InternetCPID": self.email_InternetCPID = element.text elif element.tag == "email:Flag": flag = email_Flag() flag.parse(element) self.email_Flag = flag elif element.tag == "airsyncbase:NativeBodyType": self.airsyncbase_NativeBodyType = element.text elif element.tag == "email:ContentClass": self.email_ContentClass = element.text elif element.tag == "email2:UmCallerId": self.email2_UmCalledId = element.text elif element.tag == "email2:UmUserNotes": self.email2_UmUserNotes = element.text elif element.tag == "email2:ConversationId": self.email2_ConversationId = element.text elif element.tag == "email2:ConversationIndex": self.email2_ConversationIndex = element.text elif element.tag == "email2:LastVerbExecuted": self.email2_LastVerbExecuted = element.text elif element.tag == "email2:LastVerbExecutedTime": self.email2_LastVerbExecutedTime = element.text elif element.tag == "email2:ReceivedAsBcc": self.email2_ReceivedAsBcc = element.text elif element.tag == "email2:Sender": self.email2_Sender = element.text elif element.tag == "email:Categories": categories_elements = element.get_children() for category in categories_elements: self.email_Categories.append(category.text) elif element.tag == "airsyncbase:BodyPart": self.airsyncbase_Body = airsyncbase_BodyPart.parse(element) elif element.tag == "email2:AccountId": self.email2_AccountId = element.text elif element.tag == "rm:RightsManagementLicense": continue
def parse(self, inwapxml_airsync_command): email_base = inwapxml_airsync_command.get_children() self.server_id = email_base[0].text email_elements = email_base[1].get_children() for element in email_elements: if element.tag == "email:To": self.email_To = element.text elif element.tag == "email:Cc": self.email_Cc = element.text elif element.tag == "email:From": self.email_From = element.text elif element.tag == "email:Subject": self.email_Subject = element.text elif element.tag == "email:ReplyTo": self.email_ReplyTo = element.text elif element.tag == "email:DateReceived": self.email_DateReceived = element.text elif element.tag == "email:DisplayTo": self.email_DisplayTo = element.text elif element.tag == "email:ThreadTopic": self.email_TreadTopic = element.text elif element.tag == "email:Importance": self.email_Importance = element.text elif element.tag == "email:Read": self.email_Read = element.text elif element.tag == "airsyncbase:Attachments": self.airsyncbase_Attachments = airsyncbase_Attachments.parse(element) elif element.tag == "airsyncbase:Body": body = airsyncbase_Body() body.parse(element) self.airsyncbase_Body = body elif element.tag == "email:MessageClass": self.email_MessageClass = element.text elif element.tag == "email:InternetCPID": self.email_InternetCPID = element.text elif element.tag == "email:Flag": flag = email_Flag() flag.parse(element) self.email_Flag = flag elif element.tag == "airsyncbase:NativeBodyType": self.airsyncbase_NativeBodyType = element.text elif element.tag == "email:ContentClass": self.email_ContentClass = element.text elif element.tag == "email2:UmCallerId": self.email2_UmCalledId = element.text elif element.tag == "email2:UmUserNotes": self.email2_UmUserNotes = element.text elif element.tag == "email2:ConversationId": self.email2_ConversationId = element.text elif element.tag == "email2:ConversationIndex": self.email2_ConversationIndex = element.text elif element.tag == "email2:LastVerbExecuted": self.email2_LastVerbExecuted = element.text elif element.tag == "email2:LastVerbExecutedTime": self.email2_LastVerbExecutedTime = element.text elif element.tag == "email2:ReceivedAsBcc": self.email2_ReceivedAsBcc = element.text elif element.tag == "email2:Sender": self.email2_Sender = element.text elif element.tag == "email:Categories": categories_elements = element.get_children() for category in categories_elements: self.email_Categories.append(category.text) elif element.tag == "airsyncbase:BodyPart": self.airsyncbase_Body = airsyncbase_BodyPart.parse(element) elif element.tag == "email2:AccountId": self.email2_AccountId = element.text elif element.tag == "rm:RightsManagementLicense": continue