Browse Source

Fix warnings yaml no runserver (#3280)

pull/3282/head
João Rodrigues 4 years ago
committed by GitHub
parent
commit
4707459b7b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      sapl/crispy_layout_mixin.py
  2. 6
      sapl/legacy/migracao_dados.py
  3. 2
      sapl/legacy/migracao_usuarios.py
  4. 4
      sapl/legacy/scripts/exporta_zope/exporta_zope.py
  5. 6
      sapl/legacy/scripts/ressuscita_dependencias.py
  6. 2
      sapl/legacy_migration_settings.py
  7. 2
      sapl/test_crispy_layout_mixin.py

2
sapl/crispy_layout_mixin.py

@ -337,7 +337,7 @@ def read_yaml_from_file(yaml_layout):
if isinstance(rendered, SafeText): if isinstance(rendered, SafeText):
rendered = rendered.strip() rendered = rendered.strip()
return yaml.load(rendered) return yaml.load(rendered, yaml.Loader)
def read_layout_from_yaml(yaml_layout, key): def read_layout_from_yaml(yaml_layout, key):

6
sapl/legacy/migracao_dados.py

@ -110,7 +110,9 @@ def get_renames():
includes = {} includes = {}
for app in appconfs: for app in appconfs:
app_rename_data = yaml.load( 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(): for model_name, renames in app_rename_data.items():
# armazena ou substitui includes # armazena ou substitui includes
if MODEL_RENAME_INCLUDE_PATTERN.match(model_name): 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(): def get_como_resolver_registro_votacao_ambiguo():
path = get_arquivo_resolve_registro_votacao() path = get_arquivo_resolve_registro_votacao()
if path.exists(): if path.exists():
return yaml.load(path.read_file()) return yaml.load(path.read_file(), yaml.Loader)
else: else:
return {} return {}

2
sapl/legacy/migracao_usuarios.py

@ -71,7 +71,7 @@ def migrar_usuarios(dir_repo):
ARQUIVO_USUARIOS = Path(dir_repo).child('usuarios.yaml') ARQUIVO_USUARIOS = Path(dir_repo).child('usuarios.yaml')
with open(ARQUIVO_USUARIOS, 'r') as f: 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 # conferimos de que só há um nome de usuário
assert all(nome == dados['name'] for nome, dados in usuarios.items()) assert all(nome == dados['name'] for nome, dados in usuarios.items())
usuarios = [ usuarios = [

4
sapl/legacy/scripts/exporta_zope/exporta_zope.py

@ -471,7 +471,9 @@ def dump_sapl(sigla):
finalizado = False finalizado = False
arq_mtimes = Path(repo.working_dir, 'mtimes.yaml') arq_mtimes = Path(repo.working_dir, 'mtimes.yaml')
mtimes = yaml.load( 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) _dump_sapl(data_fs_path, documentos_fs_path, destino, salvar, mtimes)
finalizado = True finalizado = True
finally: finally:

6
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): def get_dependencias_a_ressuscitar(slug):
ocorrencias = yaml.load( 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') fks_faltando = ocorrencias.get('fk')
if not fks_faltando: if not fks_faltando:
return [], [], [] return [], [], []
@ -412,7 +414,7 @@ def get_ressuscitar(slug):
def get_slug(): def get_slug():
arq = DIR_DADOS_MIGRACAO.child('siglas_para_slugs.yaml') arq = DIR_DADOS_MIGRACAO.child('siglas_para_slugs.yaml')
with open(arq, 'r') as arq: 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:] sigla = NOME_BANCO_LEGADO[-3:]
return siglas_para_slugs[sigla] return siglas_para_slugs[sigla]

2
sapl/legacy_migration_settings.py

@ -54,7 +54,7 @@ match = re.match('sapl_cm_(.*)', NOME_BANCO_LEGADO)
SIGLA_CASA = match.group(1) SIGLA_CASA = match.group(1)
_PATH_TABELA_TIMEZONES = DIR_DADOS_MIGRACAO.child('tabela_timezones.yaml') _PATH_TABELA_TIMEZONES = DIR_DADOS_MIGRACAO.child('tabela_timezones.yaml')
with open(_PATH_TABELA_TIMEZONES, 'r') as arq: 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] municipio, uf, nome_timezone = tabela_timezones[SIGLA_CASA]
if nome_timezone: if nome_timezone:
PYTZ_TIMEZONE = pytz.timezone(nome_timezone) PYTZ_TIMEZONE = pytz.timezone(nome_timezone)

2
sapl/test_crispy_layout_mixin.py

@ -18,7 +18,7 @@ ModelName:
- highlander ''' - highlander '''
with mock.patch('sapl.crispy_layout_mixin.read_yaml_from_file') as ryff: 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') == [ assert read_layout_from_yaml('....', 'ModelName') == [
['Cool Legend', ['Cool Legend',
[('name', 9), ('place', 2), ('tiny', 1)], [('name', 9), ('place', 2), ('tiny', 1)],

Loading…
Cancel
Save