From c2f2682cce6ee436510ed6bddbf5d2c595cc3766 Mon Sep 17 00:00:00 2001 From: Christoph Stahl Date: Sat, 15 Feb 2025 11:34:31 +0100 Subject: [PATCH] Dependency `alt-profanity-check` is now optional due. If it is present, it is used otherwise no profanity check is performed. This is due to the complexity of installing alt-profanity-check and only affects the server. --- pyproject.toml | 1 - syng/server.py | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 40e1f9d..9fbe691 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,6 @@ requirements-parser = "^0.11.0" [tool.poetry.extras] client = ["minio", "pillow", "qrcode", "pymediainfo", "pyyaml", "pyqt6", "mpv", "qasync"] -server = ["alt-profanity-check"] [build-system] requires = ["poetry-core"] diff --git a/syng/server.py b/syng/server.py index 63d115a..559b5ba 100644 --- a/syng/server.py +++ b/syng/server.py @@ -28,7 +28,14 @@ from typing import Any, Callable, Literal, AsyncGenerator, Optional import socketio from aiohttp import web -from profanity_check import predict + +try: + from profanity_check import predict +except ImportError: + # If the profanity_check package is not installed, use a dummy function + def predict(strings: list[str]) -> list[Literal[0, 1]]: + return [0] + from syng.sources.source import EntryNotValid