""" Compiled: 2020-09-18 10:38:53 """

#__src_file__ = "extensions/operations_document/etc/FOperationsDocumentXMLCreator.py"

import acm

from FConfirmationDocXMLSpecifier import ConfirmationDocumentXMLSpecifier
from FConfirmationSwiftXMLSpecifier import ConfirmationSwiftXMLSpecifier


#---------------------------------------------------------------------------
def __XmlToFile(xmlStr, path, fileName):

    filepath = path + fileName
    
    try:
        xmlFile = open(filepath, 'w')
        
        with xmlFile:
            xmlFile.write(xmlStr)
            acm.Log('Wrote file {}'.format(filepath))
        
    except IOError as e:
        
        acm.Log("Could not write XML message to file {}, Error: {}".format(filepath, e))

#---------------------------------------------------------------------------
def SaveXml(xmlStr, path, fileName):

    assert fileName, "No filename for the xml given"
    assert len(path), "No path given"
    assert xmlStr, "No xml data to save"

    __XmlToFile(xmlStr, path, fileName)

#---------------------------------------------------------------------------
def ToXml(xmlSpecifier):

    xmlStr = ''

    if (isinstance(xmlSpecifier, ConfirmationDocumentXMLSpecifier) or
        isinstance(xmlSpecifier, ConfirmationSwiftXMLSpecifier)):

        from FConfirmationXML import FConfirmationXML
        aelConfirmation = xmlSpecifier.GetObject('Confirmation')
        
        if aelConfirmation:
            
            confirmation = acm.FConfirmation[aelConfirmation.seqnbr]
            xmlStr = FConfirmationXML(confirmation).GenerateXmlFromTemplate()
    else:
        
        from FSettlementXML import FSettlementXML
        aelSettlement = xmlSpecifier.GetObject('Settlement')
        
        if aelSettlement:
            
            settlement = acm.FSettlement[aelSettlement.seqnbr]
            xmlStr = FSettlementXML(settlement).GenerateXmlFromTemplate()

    return xmlStr

5be687f5c9945972cd7201a83bb644ff2dde57f6
<mask token>


def SaveXml(xmlStr, path, fileName):
    assert fileName, 'No filename for the xml given'
    assert len(path), 'No path given'
    assert xmlStr, 'No xml data to save'
    __XmlToFile(xmlStr, path, fileName)


<mask token>

<mask token>


def SaveXml(xmlStr, path, fileName):
    assert fileName, 'No filename for the xml given'
    assert len(path), 'No path given'
    assert xmlStr, 'No xml data to save'
    __XmlToFile(xmlStr, path, fileName)


def ToXml(xmlSpecifier):
    xmlStr = ''
    if isinstance(xmlSpecifier, ConfirmationDocumentXMLSpecifier
        ) or isinstance(xmlSpecifier, ConfirmationSwiftXMLSpecifier):
        from FConfirmationXML import FConfirmationXML
        aelConfirmation = xmlSpecifier.GetObject('Confirmation')
        if aelConfirmation:
            confirmation = acm.FConfirmation[aelConfirmation.seqnbr]
            xmlStr = FConfirmationXML(confirmation).GenerateXmlFromTemplate()
    else:
        from FSettlementXML import FSettlementXML
        aelSettlement = xmlSpecifier.GetObject('Settlement')
        if aelSettlement:
            settlement = acm.FSettlement[aelSettlement.seqnbr]
            xmlStr = FSettlementXML(settlement).GenerateXmlFromTemplate()
    return xmlStr

<mask token>


def __XmlToFile(xmlStr, path, fileName):
    filepath = path + fileName
    try:
        xmlFile = open(filepath, 'w')
        with xmlFile:
            xmlFile.write(xmlStr)
            acm.Log('Wrote file {}'.format(filepath))
    except IOError as e:
        acm.Log('Could not write XML message to file {}, Error: {}'.format(
            filepath, e))


def SaveXml(xmlStr, path, fileName):
    assert fileName, 'No filename for the xml given'
    assert len(path), 'No path given'
    assert xmlStr, 'No xml data to save'
    __XmlToFile(xmlStr, path, fileName)


def ToXml(xmlSpecifier):
    xmlStr = ''
    if isinstance(xmlSpecifier, ConfirmationDocumentXMLSpecifier
        ) or isinstance(xmlSpecifier, ConfirmationSwiftXMLSpecifier):
        from FConfirmationXML import FConfirmationXML
        aelConfirmation = xmlSpecifier.GetObject('Confirmation')
        if aelConfirmation:
            confirmation = acm.FConfirmation[aelConfirmation.seqnbr]
            xmlStr = FConfirmationXML(confirmation).GenerateXmlFromTemplate()
    else:
        from FSettlementXML import FSettlementXML
        aelSettlement = xmlSpecifier.GetObject('Settlement')
        if aelSettlement:
            settlement = acm.FSettlement[aelSettlement.seqnbr]
            xmlStr = FSettlementXML(settlement).GenerateXmlFromTemplate()
    return xmlStr

<mask token>
import acm
from FConfirmationDocXMLSpecifier import ConfirmationDocumentXMLSpecifier
from FConfirmationSwiftXMLSpecifier import ConfirmationSwiftXMLSpecifier


def __XmlToFile(xmlStr, path, fileName):
    filepath = path + fileName
    try:
        xmlFile = open(filepath, 'w')
        with xmlFile:
            xmlFile.write(xmlStr)
            acm.Log('Wrote file {}'.format(filepath))
    except IOError as e:
        acm.Log('Could not write XML message to file {}, Error: {}'.format(
            filepath, e))


def SaveXml(xmlStr, path, fileName):
    assert fileName, 'No filename for the xml given'
    assert len(path), 'No path given'
    assert xmlStr, 'No xml data to save'
    __XmlToFile(xmlStr, path, fileName)


def ToXml(xmlSpecifier):
    xmlStr = ''
    if isinstance(xmlSpecifier, ConfirmationDocumentXMLSpecifier
        ) or isinstance(xmlSpecifier, ConfirmationSwiftXMLSpecifier):
        from FConfirmationXML import FConfirmationXML
        aelConfirmation = xmlSpecifier.GetObject('Confirmation')
        if aelConfirmation:
            confirmation = acm.FConfirmation[aelConfirmation.seqnbr]
            xmlStr = FConfirmationXML(confirmation).GenerateXmlFromTemplate()
    else:
        from FSettlementXML import FSettlementXML
        aelSettlement = xmlSpecifier.GetObject('Settlement')
        if aelSettlement:
            settlement = acm.FSettlement[aelSettlement.seqnbr]
            xmlStr = FSettlementXML(settlement).GenerateXmlFromTemplate()
    return xmlStr

""" Compiled: 2020-09-18 10:38:53 """

#__src_file__ = "extensions/operations_document/etc/FOperationsDocumentXMLCreator.py"

import acm

from FConfirmationDocXMLSpecifier import ConfirmationDocumentXMLSpecifier
from FConfirmationSwiftXMLSpecifier import ConfirmationSwiftXMLSpecifier


#---------------------------------------------------------------------------
def __XmlToFile(xmlStr, path, fileName):

    filepath = path + fileName
    
    try:
        xmlFile = open(filepath, 'w')
        
        with xmlFile:
            xmlFile.write(xmlStr)
            acm.Log('Wrote file {}'.format(filepath))
        
    except IOError as e:
        
        acm.Log("Could not write XML message to file {}, Error: {}".format(filepath, e))

#---------------------------------------------------------------------------
def SaveXml(xmlStr, path, fileName):

    assert fileName, "No filename for the xml given"
    assert len(path), "No path given"
    assert xmlStr, "No xml data to save"

    __XmlToFile(xmlStr, path, fileName)

#---------------------------------------------------------------------------
def ToXml(xmlSpecifier):

    xmlStr = ''

    if (isinstance(xmlSpecifier, ConfirmationDocumentXMLSpecifier) or
        isinstance(xmlSpecifier, ConfirmationSwiftXMLSpecifier)):

        from FConfirmationXML import FConfirmationXML
        aelConfirmation = xmlSpecifier.GetObject('Confirmation')
        
        if aelConfirmation:
            
            confirmation = acm.FConfirmation[aelConfirmation.seqnbr]
            xmlStr = FConfirmationXML(confirmation).GenerateXmlFromTemplate()
    else:
        
        from FSettlementXML import FSettlementXML
        aelSettlement = xmlSpecifier.GetObject('Settlement')
        
        if aelSettlement:
            
            settlement = acm.FSettlement[aelSettlement.seqnbr]
            xmlStr = FSettlementXML(settlement).GenerateXmlFromTemplate()

    return xmlStr
