From 5832141df58fb3c7a703d8474f47a02174aa45bb Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Mon, 4 Jun 2018 09:44:08 -0300 Subject: [PATCH] [NEW] Analise resposta GenerateDS --- pynfe/processamento/resposta.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pynfe/processamento/resposta.py diff --git a/pynfe/processamento/resposta.py b/pynfe/processamento/resposta.py new file mode 100644 index 0000000..2551ac4 --- /dev/null +++ b/pynfe/processamento/resposta.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018 - TODAY Luis Felipe Mileo - KMEE INFORMATICA LTDA +# License AGPL-3 - See https://www.gnu.org/licenses/lgpl-3.0.html + +import re +from pynfe.utils import etree + + +def analisar_retorno(retorno, classe_resposta): + + retorno.raise_for_status() + + match = re.search('(.*?)', retorno.text) + + if match: + resultado = etree.tostring(etree.fromstring(match.group(1))[0]) + classe_resposta.Validate_simpletypes_ = False + retorno = classe_resposta.parseString(resultado.encode('utf-8')) + + return retorno