Browse Source

substitui rtyaml por yaml e remove do projeto

pull/3256/head
Leandro Roberto 4 years ago
parent
commit
5abc0d3006
  1. 1
      requirements/requirements.txt
  2. 9
      sapl/crispy_layout_mixin.py
  3. 4
      sapl/test_crispy_layout_mixin.py
  4. 1
      setup.py

1
requirements/requirements.txt

@ -21,7 +21,6 @@ python-decouple==3.1
psycopg2-binary==2.7.6.1
pyyaml==5.3.1
pytz==2019.3
rtyaml==1.0.0
python-magic==0.4.15
unipath==1.1
WeasyPrint==51

9
sapl/crispy_layout_mixin.py

@ -7,7 +7,7 @@ from django import template
from django.urls import reverse, reverse_lazy
from django.utils import formats
from django.utils.translation import ugettext as _
import rtyaml
import yaml
def heads_and_tails(list_of_lists):
@ -332,17 +332,12 @@ class CrispyLayoutFormMixin:
def read_yaml_from_file(yaml_layout):
from django.utils.safestring import SafeText
# TODO cache this at application level
t = template.loader.get_template(yaml_layout)
# aqui é importante converter para str pois, dependendo do ambiente,
# o rtyaml pode usar yaml.CSafeLoader, que exige str ou stream
rendered = str(t.render())
# Força conversão para string caso seja SafeText.
if isinstance(rendered, SafeText):
rendered = rendered.strip()
return rtyaml.load(rendered)
return yaml.load(rendered)
def read_layout_from_yaml(yaml_layout, key):

4
sapl/test_crispy_layout_mixin.py

@ -1,6 +1,6 @@
from unittest import mock
import rtyaml
import yaml
from sapl.crispy_layout_mixin import read_layout_from_yaml
@ -18,7 +18,7 @@ ModelName:
- highlander '''
with mock.patch('sapl.crispy_layout_mixin.read_yaml_from_file') as ryff:
ryff.return_value = rtyaml.load(stub_content)
ryff.return_value = yaml.load(stub_content)
assert read_layout_from_yaml('....', 'ModelName') == [
['Cool Legend',
[('name', 9), ('place', 2), ('tiny', 1)],

1
setup.py

@ -31,7 +31,6 @@ install_requires = [
'psycopg2-binary==2.7.6.1',
'pyyaml==4.2b1',
'pytz==2018.9',
'rtyaml==0.0.5',
'python-magic==0.4.15',
'unipath==1.1',
'WeasyPrint==44',

Loading…
Cancel
Save