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 63d2df0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/erpbrasil/edoc/resposta.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

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 @@ -18,10 +22,9 @@ 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.?>(.*?)</[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 63d2df0

Please sign in to comment.