oc-facho/facho/fe/form_xml/utils.py
alnus@disroot.org 5315a7fab9 encode xml
FossilOrigin-Name: fb4563f3b117dfdd0be637c93efe2197bb49d15a436d882b4ad650b681c205b3
2020-10-31 03:29:32 +00:00

16 lines
590 B
Python

from .. import fe
__all__ = ['DIANWrite', 'DIANWriteSigned']
def DIANWrite(xml, filename):
document = xml.tostring(xml_declaration=True, encoding='UTF-8')
with open(filename, 'w') as f:
f.write(document)
def DIANWriteSigned(xml, filename, private_key, passphrase, use_cache_policy=False):
document = xml.tostring(xml_declaration=True, encoding='UTF-8').encode('utf-8')
signer = fe.DianXMLExtensionSigner(private_key, passphrase=passphrase, mockpolicy=use_cache_policy)
with open(filename, 'w') as f:
f.write(signer.sign_xml_string(document))