squeaknode/squeakserver/server/squeak_validator.py
2020-07-18 19:25:31 -07:00

24 lines
540 B
Python

import logging
from squeak.core import CheckSqueak, CheckSqueakError, CSqueak
logger = logging.getLogger(__name__)
class SqueakValidator(object):
"""Validates incoming squeaks
"""
def __init__(self) -> None:
pass
def validate(self, squeak: CSqueak) -> bool:
if not squeak:
return False
try:
CheckSqueak(squeak)
return True
except CheckSqueakError as e:
logger.info("Got invalid squeak with error: {}".format(e))
return False