nuevas rutinas para almacenar xml.
facho/fe/form_xml.py(DIANWrite): escribe xml a archivo. facho/fe/form_xml.py(DIANWriteSigned): escribe xml firmado a archivo. FossilOrigin-Name: fbadde1c5c263033ccaa60c9fb69113829bc405adef684bc3d6497d56f1b95c3
This commit is contained in:
@@ -69,8 +69,7 @@ class FeXML(FachoXML):
|
||||
self._cn = root.rstrip('/')
|
||||
#self.find_or_create_element(self._cn)
|
||||
|
||||
# MACHETE se elimina xml namespace fe
|
||||
def tostringMACHETE(self, **kw):
|
||||
def tostring(self, **kw):
|
||||
return super().tostring(**kw)\
|
||||
.replace("fe:", "")\
|
||||
.replace("xmlns:fe", "xmlns")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from . import fe
|
||||
from .form import *
|
||||
|
||||
|
||||
class DIANInvoiceXML(fe.FeXML):
|
||||
"""
|
||||
DianInvoiceXML mapea objeto form.Invoice a XML segun
|
||||
@@ -389,3 +390,16 @@ class DIANInvoiceXML(fe.FeXML):
|
||||
fexml.set_payment_mean(invoice)
|
||||
|
||||
return fexml
|
||||
|
||||
|
||||
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')
|
||||
signer = fe.DianXMLExtensionSigner(private_key, passphrase=passphrase, mockpolicy=use_cache_policy)
|
||||
with open(filename, 'w') as f:
|
||||
f.write(signer.sign_xml_string(document))
|
||||
|
||||
Reference in New Issue
Block a user