diff --git a/sapl/crispy_layout_mixin.py b/sapl/crispy_layout_mixin.py index 9c23c8154..8e6a61806 100644 --- a/sapl/crispy_layout_mixin.py +++ b/sapl/crispy_layout_mixin.py @@ -337,7 +337,7 @@ def read_yaml_from_file(yaml_layout): if isinstance(rendered, SafeText): rendered = rendered.strip() - return yaml.load(rendered) + return yaml.load(rendered, yaml.Loader) def read_layout_from_yaml(yaml_layout, key): diff --git a/sapl/legacy/migracao_dados.py b/sapl/legacy/migracao_dados.py index 1def7f9c3..46e1fa7cf 100644 --- a/sapl/legacy/migracao_dados.py +++ b/sapl/legacy/migracao_dados.py @@ -110,7 +110,9 @@ def get_renames(): includes = {} for app in appconfs: app_rename_data = yaml.load( - pkg_resources.resource_string(app.module.__name__, 'legacy.yaml')) + pkg_resources.resource_string(app.module.__name__, 'legacy.yaml'), + yaml.Loader + ) for model_name, renames in app_rename_data.items(): # armazena ou substitui includes if MODEL_RENAME_INCLUDE_PATTERN.match(model_name): @@ -1175,7 +1177,7 @@ def get_arquivo_resolve_registro_votacao(): def get_como_resolver_registro_votacao_ambiguo(): path = get_arquivo_resolve_registro_votacao() if path.exists(): - return yaml.load(path.read_file()) + return yaml.load(path.read_file(), yaml.Loader) else: return {} diff --git a/sapl/legacy/migracao_usuarios.py b/sapl/legacy/migracao_usuarios.py index d767343a3..6fa9cc7ea 100644 --- a/sapl/legacy/migracao_usuarios.py +++ b/sapl/legacy/migracao_usuarios.py @@ -71,7 +71,7 @@ def migrar_usuarios(dir_repo): ARQUIVO_USUARIOS = Path(dir_repo).child('usuarios.yaml') with open(ARQUIVO_USUARIOS, 'r') as f: - usuarios = yaml.load(f) + usuarios = yaml.load(f, yaml.Loader) # conferimos de que só há um nome de usuário assert all(nome == dados['name'] for nome, dados in usuarios.items()) usuarios = [ diff --git a/sapl/legacy/scripts/exporta_zope/exporta_zope.py b/sapl/legacy/scripts/exporta_zope/exporta_zope.py index bec8595cf..36c570faa 100755 --- a/sapl/legacy/scripts/exporta_zope/exporta_zope.py +++ b/sapl/legacy/scripts/exporta_zope/exporta_zope.py @@ -471,7 +471,9 @@ def dump_sapl(sigla): finalizado = False arq_mtimes = Path(repo.working_dir, 'mtimes.yaml') mtimes = yaml.load( - arq_mtimes.read_file()) if arq_mtimes.exists() else {} + arq_mtimes.read_file(), + yaml.Loader + ) if arq_mtimes.exists() else {} _dump_sapl(data_fs_path, documentos_fs_path, destino, salvar, mtimes) finalizado = True finally: diff --git a/sapl/legacy/scripts/ressuscita_dependencias.py b/sapl/legacy/scripts/ressuscita_dependencias.py index 5e12efc01..e45143567 100644 --- a/sapl/legacy/scripts/ressuscita_dependencias.py +++ b/sapl/legacy/scripts/ressuscita_dependencias.py @@ -197,7 +197,9 @@ Para facilitar sua conferência, seguem os links para as proposições envolvida def get_dependencias_a_ressuscitar(slug): ocorrencias = yaml.load( - Path(DIR_REPO.child('ocorrencias.yaml').read_file())) + Path(DIR_REPO.child('ocorrencias.yaml').read_file()), + yaml.Loader + ) fks_faltando = ocorrencias.get('fk') if not fks_faltando: return [], [], [] @@ -412,7 +414,7 @@ def get_ressuscitar(slug): def get_slug(): arq = DIR_DADOS_MIGRACAO.child('siglas_para_slugs.yaml') with open(arq, 'r') as arq: - siglas_para_slugs = yaml.load(arq) + siglas_para_slugs = yaml.load(arq, yaml.Loader) sigla = NOME_BANCO_LEGADO[-3:] return siglas_para_slugs[sigla] diff --git a/sapl/legacy_migration_settings.py b/sapl/legacy_migration_settings.py index ce0029937..463fbb7a6 100644 --- a/sapl/legacy_migration_settings.py +++ b/sapl/legacy_migration_settings.py @@ -54,7 +54,7 @@ match = re.match('sapl_cm_(.*)', NOME_BANCO_LEGADO) SIGLA_CASA = match.group(1) _PATH_TABELA_TIMEZONES = DIR_DADOS_MIGRACAO.child('tabela_timezones.yaml') with open(_PATH_TABELA_TIMEZONES, 'r') as arq: - tabela_timezones = yaml.load(arq) + tabela_timezones = yaml.load(arq, yaml.Loader) municipio, uf, nome_timezone = tabela_timezones[SIGLA_CASA] if nome_timezone: PYTZ_TIMEZONE = pytz.timezone(nome_timezone) diff --git a/sapl/test_crispy_layout_mixin.py b/sapl/test_crispy_layout_mixin.py index 7ffca2306..a643d5083 100644 --- a/sapl/test_crispy_layout_mixin.py +++ b/sapl/test_crispy_layout_mixin.py @@ -18,7 +18,7 @@ ModelName: - highlander ''' with mock.patch('sapl.crispy_layout_mixin.read_yaml_from_file') as ryff: - ryff.return_value = yaml.load(stub_content) + ryff.return_value = yaml.load(stub_content, yaml.Loader) assert read_layout_from_yaml('....', 'ModelName') == [ ['Cool Legend', [('name', 9), ('place', 2), ('tiny', 1)],