From b902a05c3a1cd57795ba187c09fd88b07307ccf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20Mil=C3=A9o?= Date: Tue, 16 Jul 2024 20:58:07 -0300 Subject: [PATCH] [REF] Combined pattern analisar_retorno_raw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luis Felipe Miléo --- src/erpbrasil/edoc/resposta.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/erpbrasil/edoc/resposta.py b/src/erpbrasil/edoc/resposta.py index 8acca86..4e97ddf 100644 --- a/src/erpbrasil/edoc/resposta.py +++ b/src/erpbrasil/edoc/resposta.py @@ -7,6 +7,12 @@ from lxml import etree +combined_pattern = "|".join([ + "(.*?)", + "<[a-zA-Z0-9:]Body.?>(.*?)" +]) + + class RetornoSoap: def __init__(self, webservice, raiz, xml, retorno, resposta): self.webservice = webservice @@ -18,7 +24,7 @@ def __init__(self, webservice, raiz, xml, retorno, resposta): def analisar_retorno_raw(operacao, raiz, xml, retorno, classe): retorno.raise_for_status() - pattern = r"<[a-zA-Z0-9:]Body.?>(.*?)" + pattern = re.compile(combined_pattern) match = re.search(pattern, retorno.text.replace("\n", "")) if match: xml_resposta = match.group(1)