From c755d90ef0182dffccd9511239517a3f6b2d5d63 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Tue, 16 Apr 2019 17:36:10 -0300 Subject: [PATCH] HOT-FIX: retira acentos de XML do LexML --- sapl/lexml/OAIServer.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sapl/lexml/OAIServer.py b/sapl/lexml/OAIServer.py index 4964dbeb9..9783f2fa6 100644 --- a/sapl/lexml/OAIServer.py +++ b/sapl/lexml/OAIServer.py @@ -1,3 +1,4 @@ +import unicodedata from datetime import datetime import oaipmh @@ -123,13 +124,23 @@ class OAIServer: else: return None + @staticmethod + def remove_acentos(linha): + res = unicodedata.normalize('NFKD', linha).encode('ASCII', 'ignore') + res = res.decode("UTF-8") + remove_list = ["\'", "\"", "-"] + for i in remove_list: + res = res.replace(i, "") + return res + def monta_urn(self, norma, esfera): if norma: urn = 'urn:lex:br;' esferas = {'M': 'municipal', 'E': 'estadual'} - municipio = casa.municipio.lower() + municipio = self.remove_acentos(casa.municipio.lower()) uf_map = dict(LISTA_DE_UFS) uf_desc = uf_map.get(casa.uf.upper(), '').lower() + uf_desc = self.remove_acentos(uf_desc) for x in [' ', '.de.', '.da.', '.das.', '.do.', '.dos.']: municipio = municipio.replace(x, '.') uf_desc = uf_desc.replace(x, '.')