From f49ad907793dd97cda7e81da10833a9b150d8b9d Mon Sep 17 00:00:00 2001 From: Junior Tada Date: Thu, 20 Aug 2015 15:00:21 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20bug=20assinatura=20quando?= =?UTF-8?q?=20evento=20na=20tag=20infEvento?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pynfe/processamento/assinatura.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pynfe/processamento/assinatura.py b/pynfe/processamento/assinatura.py index 72233e5..2b16130 100644 --- a/pynfe/processamento/assinatura.py +++ b/pynfe/processamento/assinatura.py @@ -31,9 +31,11 @@ class AssinaturaA1(Assinatura): siginfo = etree.SubElement(raiz, 'SignedInfo') etree.SubElement(siginfo, 'CanonicalizationMethod', Algorithm='http://www.w3.org/TR/2001/REC-xml-c14n-20010315') etree.SubElement(siginfo, 'SignatureMethod', Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1') - if xml.findall('infNFe')[0].attrib['Id']: + # Tenta achar a tag infNFe + try: ref = etree.SubElement(siginfo, 'Reference', URI='#'+xml.findall('infNFe')[0].attrib['Id']) - elif xml.findall('infEvento')[0].attrib['Id']: + # Caso nao tenha a tag infNFe, procura a tag infEvento + except IndexError: tag = 'infEvento' ref = etree.SubElement(siginfo, 'Reference', URI='#'+xml.findall('infEvento')[0].attrib['Id']) trans = etree.SubElement(ref, 'Transforms')