mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-19 13:18:26 +02:00
24 lines
540 B
Python
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
|