Move YAML code to its own module
Code now resides in common.serialization in the form of two new functions: yaml_load and yaml_dump. Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -2,15 +2,12 @@ from __future__ import unicode_literals
|
||||
|
||||
import yaml
|
||||
|
||||
try:
|
||||
from yaml import CSafeLoader as SafeLoader
|
||||
except ImportError:
|
||||
from yaml import SafeLoader
|
||||
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from mayan.apps.common.serialization import yaml_load
|
||||
|
||||
|
||||
class SettingForm(forms.Form):
|
||||
value = forms.CharField(
|
||||
@@ -38,7 +35,7 @@ class SettingForm(forms.Form):
|
||||
)
|
||||
|
||||
try:
|
||||
yaml.load(stream=self.cleaned_data['value'], Loader=SafeLoader)
|
||||
yaml_load(stream=self.cleaned_data['value'])
|
||||
except yaml.YAMLError:
|
||||
raise ValidationError(
|
||||
_(
|
||||
|
||||
Reference in New Issue
Block a user