mirror of
https://github.com/EDCD/EDDN.git
synced 2025-06-06 10:23:08 +03:00
Make Validator its own class, because it's going to want state soon.
This commit is contained in:
parent
2d406f9e25
commit
fdeea2f7c2
@ -11,7 +11,7 @@ import zlib
|
||||
import zmq.green as zmq
|
||||
from eddn import __version__ as EDDN_VERSION
|
||||
from eddn.conf import Settings
|
||||
from eddn.Validator import validate, ValidationSeverity
|
||||
from eddn.Validator import Validator, ValidationSeverity
|
||||
|
||||
from gevent import monkey
|
||||
monkey.patch_all()
|
||||
@ -28,6 +28,8 @@ sender = context.socket(zmq.PUB)
|
||||
for binding in Settings.GATEWAY_SENDER_BINDINGS:
|
||||
sender.bind(binding)
|
||||
|
||||
validator = Validator()
|
||||
|
||||
|
||||
def push_message(string_message):
|
||||
"""
|
||||
@ -110,7 +112,7 @@ def parse_and_error_handle(data):
|
||||
logger.error("Error to %s: %s" % (get_remote_address(), exc.message))
|
||||
return exc.message
|
||||
|
||||
validationResults = validate(parsed_message)
|
||||
validationResults = validator.validate(parsed_message)
|
||||
|
||||
if validationResults.severity <= ValidationSeverity.WARN:
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
from enum import IntEnum
|
||||
|
||||
|
||||
def validate(json_object):
|
||||
class Validator(object):
|
||||
|
||||
def validate(self, json_object):
|
||||
results = ValidationResults()
|
||||
|
||||
if "$schemaRef" not in json_object:
|
||||
|
Loading…
x
Reference in New Issue
Block a user