Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
from __future__ import absolute_import
from cerberus.validator import DocumentError, Validator
from cerberus.schema import rules_set_registry, schema_registry, SchemaError
from cerberus.utils import TypeDefinition
__version__ = "1.2"
__all__ = [
DocumentError.__name__,
SchemaError.__name__,
TypeDefinition.__name__,
Validator.__name__,
'schema_registry',
'rules_set_registry',
]
def get_Validator_class():
global Validator
if 'Validator' not in globals():
from cerberus.validator import Validator
return Validator
from cerberus.validator import DocumentError, Validator
from cerberus.schema import rules_set_registry, schema_registry, SchemaError
from cerberus.utils import TypeDefinition
try:
__version__ = get_distribution("Cerberus").version
except DistributionNotFound:
__version__ = "unknown"
__all__ = [
DocumentError.__name__,
SchemaError.__name__,
TypeDefinition.__name__,
Validator.__name__,
"schema_registry",
"rules_set_registry",
]
def get_Validator_class():
global Validator
if 'Validator' not in globals():
from cerberus.validator import Validator
return Validator
raise ValidationError({'package': ['No module named {}'.format(package)]})
def load_schema(directory, filename=None):
try:
return load_yaml_schema(directory)
except IOError:
try:
return load_py_schema(directory)
except ImportError:
raise IOError(
'Neither .yaml nor .py schema found in %s' %
directory)
class PatchedValidator(Validator):
def _validate_description(self, description, field, value):
""" {'type': 'string'} """
pass
def _validate_values_description(self, values_description, field, value):
""" {'type': 'dict'} """
pass
def _validate_tutorial_link(self, tutorial_link, field, value):
""" {'type': 'string'} """
pass
def _validate_examples(self, examples, field, value):
""" {'type': 'dict'} """
pass
raise ValidationError({'package': ['No module named {}'.format(package)]})
def load_schema(directory, filename=None):
try:
return load_yaml_schema(directory)
except IOError:
try:
return load_py_schema(directory)
except ImportError:
raise IOError(
'Neither .yaml nor .py schema found in %s' %
directory)
class PatchedValidator(Validator):
def _validate_description(self, description, field, value):
""" {'type': 'string'} """
pass
def _validate_values_description(self, values_description, field, value):
""" {'type': 'dict'} """
pass
def _validate_tutorial_link(self, tutorial_link, field, value):
""" {'type': 'string'} """
pass
def _validate_examples(self, examples, field, value):
""" {'type': 'dict'} """
pass