Esempio n. 1
0
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
Esempio n. 2
0
 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
Esempio n. 3
0
 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
Esempio n. 4
0
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
Esempio n. 5
0
    def parse(wapxml):

        namespace = "itemoperations"
        root_tag = "ItemOperations"

        root_element = wapxml.get_root()
        if root_element.get_xmlns() != namespace:
            raise AttributeError(
                "Xmlns '%s' submitted to '%s' parser. Should be '%s'." %
                (root_element.get_xmlns(), root_tag, namespace))
        if root_element.tag != root_tag:
            raise AttributeError(
                "Root tag '%s' submitted to '%s' parser. Should be '%s'." %
                (root_element.tag, root_tag, root_tag))

        itemoperations_itemoperations_children = root_element.get_children()

        itemoperations_itemoperations_status = None

        responses = []

        for element in itemoperations_itemoperations_children:
            if element.tag is "Status":
                itemoperations_itemoperations_status = element.text
                if itemoperations_itemoperations_status != "1":
                    print "FolderSync Exception: %s" % itemoperations_itemoperations_status
            elif element.tag == "Response":
                response_elements = element.get_children()
                for response_element in response_elements:
                    if response_element.tag == "EmptyFolderContents":
                        efc_elements = response_element.get_children()
                        for efc_element in efc_elements:
                            if efc_element.tag == "Status":
                                efc_status = efc_element.text
                            elif efc_element.tag == "airsync:CollectionId":
                                efc_collectionid = efc_element.text
                        responses.append(("EmptyFolderContents", efc_status,
                                          efc_collectionid))
                    elif response_element.tag == "Fetch":
                        fetch_elements = response_element.get_children()
                        fetch_id = None
                        fetch_properties = None
                        fetch_class = None
                        for fetch_element in fetch_elements:
                            if fetch_element.tag == "Status":
                                fetch_status = fetch_element.text
                            elif fetch_element.tag == "search:LongId":
                                fetch_id = fetch_element.text
                            elif fetch_element.tag == "airsync:CollectionId":
                                fetch_id = fetch_element.text
                            elif fetch_element.tag == "airsync:ServerId":
                                fetch_id = fetch_element.text
                            elif fetch_element.tag == "documentlibrary:LinkId":
                                fetch_id = fetch_element.text
                            elif fetch_element.tag == "airsync:Class":
                                fetch_class = fetch_element.text
                            elif fetch_element.tag == "Properties":
                                property_elements = fetch_element.get_children(
                                )
                                fetch_properties = {}
                                for property_element in property_elements:
                                    if property_element.tag == "Range":
                                        fetch_properties.update(
                                            {"Range": property_element.text})
                                    elif property_element.tag == "Data":
                                        fetch_properties.update(
                                            {"Data": property_element.text})
                                    elif property_element.tag == "Part":
                                        fetch_properties.update(
                                            {"Part": property_element.text})
                                    elif property_element.tag == "Version":  #datetime
                                        fetch_properties.update(
                                            {"Version": property_element.text})
                                    elif property_element.tag == "Total":
                                        fetch_properties.update(
                                            {"Total": property_element.text})
                                    elif property_element.tag == "airsyncbase:Body":
                                        fetch_properties.update({
                                            "Body":
                                            airsyncbase_Body(property_element)
                                        })
                                    elif property_element.tag == "airsyncbase:BodyPart":
                                        fetch_properties.update({
                                            "BodyPart":
                                            airsyncbase_BodyPart(
                                                property_element)
                                        })
                                    elif property_element.tag == "rm:RightsManagementLicense":
                                        fetch_properties.update({
                                            "RightsManagementLicense":
                                            property_element
                                        })  #need to create rm license parser
                        responses.append(("Fetch", fetch_status, fetch_id,
                                          fetch_properties, fetch_class))
                    elif response_element.tag == "Move":
                        move_elements = response_element.get_children()
                        for move_element in move_elements:
                            if move_element.tag == "Status":
                                move_status = move_element.text
                            elif move_element.tag == "ConversationId":
                                move_conversationid = move_element.text
                        responses.append(
                            ("Move", move_status, move_conversationid))
        return responses