Actually create our PREMIS Event XML

def createPREMISEventXML(eventType, agentIdentifier, eventDetail, eventOutcome,
                         outcomeDetail=None, eventIdentifier=None,
                         linkObjectList=[], eventDate=None):
    """
    Actually create our PREMIS Event XML
    """

    eventXML = etree.Element(PREMIS + "event", nsmap=PREMIS_NSMAP)
    eventIDXML = etree.SubElement(eventXML, PREMIS + "eventIdentifier")
    eventTypeXML = etree.SubElement(eventXML, PREMIS + "eventType")
    eventTypeXML.text = eventType
    eventIDTypeXML = etree.SubElement(
        eventIDXML, PREMIS + "eventIdentifierType"
    )
    eventIDTypeXML.text = \
        "http://purl.org/net/untl/vocabularies/identifier-qualifiers/#UUID"
    eventIDValueXML = etree.SubElement(
        eventIDXML, PREMIS + "eventIdentifierValue"
    )
    if eventIdentifier:
        eventIDValueXML.text = eventIdentifier
    else:
        eventIDValueXML.text = uuid.uuid4().hex
    eventDateTimeXML = etree.SubElement(eventXML, PREMIS + "eventDateTime")
    if eventDate is None:
        eventDateTimeXML.text = xsDateTime_format(datetime.utcnow())
    else:
        eventDateTimeXML.text = xsDateTime_format(eventDate)
    eventDetailXML = etree.SubElement(eventXML, PREMIS + "eventDetail")
    eventDetailXML.text = eventDetail
    eventOutcomeInfoXML = etree.SubElement(
        eventXML, PREMIS + "eventOutcomeInformation"
    )
    eventOutcomeXML = etree.SubElement(
        eventOutcomeInfoXML, PREMIS + "eventOutcome"
    )
    eventOutcomeXML.text = eventOutcome
    if outcomeDetail:
        eventOutcomeDetailXML = etree.SubElement(
            eventOutcomeInfoXML, PREMIS + "eventOutcomeDetail"
        )
        eventOutcomeDetailNoteXML = etree.SubElement(
            eventOutcomeDetailXML, PREMIS + "eventOutcomeDetailNote"
        )
        eventOutcomeDetailNoteXML.text = outcomeDetail
        # Assuming it's a list of 3-item tuples here [ ( identifier, type, role) ]
    linkAgentIDXML = etree.SubElement(
        eventXML, PREMIS + "linkingAgentIdentifier")
    linkAgentIDTypeXML = etree.SubElement(
        linkAgentIDXML, PREMIS + "linkingAgentIdentifierType"
    )
    linkAgentIDTypeXML.text = \
        "http://purl.org/net/untl/vocabularies/identifier-qualifiers/#URL"
    linkAgentIDValueXML = etree.SubElement(
        linkAgentIDXML, PREMIS + "linkingAgentIdentifierValue"
    )
    linkAgentIDValueXML.text = agentIdentifier
    linkAgentIDRoleXML = etree.SubElement(
        linkAgentIDXML, PREMIS + "linkingAgentRole"
    )
    linkAgentIDRoleXML.text = \
        "http://purl.org/net/untl/vocabularies/linkingAgentRoles/#executingProgram"
    for linkObject in linkObjectList:
        linkObjectIDXML = etree.SubElement(
            eventXML, PREMIS + "linkingObjectIdentifier"
        )
        linkObjectIDTypeXML = etree.SubElement(
            linkObjectIDXML, PREMIS + "linkingObjectIdentifierType"
        )
        linkObjectIDTypeXML.text = linkObject[1]
        linkObjectIDValueXML = etree.SubElement(
            linkObjectIDXML, PREMIS + "linkingObjectIdentifierValue"
        )
        linkObjectIDValueXML.text = linkObject[0]
        if linkObject[2]:
            linkObjectRoleXML = etree.SubElement(
                linkObjectIDXML, PREMIS + "linkingObjectRole"
            )
            linkObjectRoleXML.text = linkObject[2]
    return eventXML