Skip to content

Commit

Permalink
[REF] Combined pattern analisar_retorno_raw
Browse files Browse the repository at this point in the history
Signed-off-by: Luis Felipe Miléo <[email protected]>
  • Loading branch information
mileo authored and corredato committed Jul 17, 2024
1 parent 88c8a57 commit d815d08
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/erpbrasil/edoc/resposta.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

from lxml import etree

combined_pattern = re.compile(
r"<soap:Body>(.*?)</soap:Body>|<[a-zA-Z0-9:]*Body[^>]*>(.*?)</[a-zA-Z0-9:]*Body>"
)

class RetornoSoap:
def __init__(self, webservice, raiz, xml, retorno, resposta):
Expand All @@ -15,13 +18,11 @@ def __init__(self, webservice, raiz, xml, retorno, resposta):
self.resposta = resposta
self.retorno = retorno


def analisar_retorno_raw(operacao, raiz, xml, retorno, classe):
retorno.raise_for_status()
pattern = r"<[a-zA-Z0-9:]Body.?>(.*?)</[a-zA-Z0-9:]*Body>"
match = re.search(pattern, retorno.text.replace("\n", ""))
match = re.search(combined_pattern, retorno.text.replace("\n", ""))
if match:
xml_resposta = match.group(1)
xml_resposta = match.group(1) or match.group(2)
xml_etree = etree.fromstring(xml_resposta)
resultado = xml_etree[0]

Expand Down

0 comments on commit d815d08

Please sign in to comment.