Replace profanity-filter with better-profanity

Since Heroku refuses to let me downloda the spaCy model, we're going
with this instead. :/
This commit is contained in:
Xevion
2022-03-30 15:57:47 -05:00
parent 3a0c1690d3
commit 73d9fd5454
3 changed files with 21 additions and 16 deletions

View File

@@ -14,9 +14,8 @@ faker = "*"
humanize = "*" humanize = "*"
gunicorn = "*" gunicorn = "*"
psycopg2 = "*" psycopg2 = "*"
profanity-filter = "*"
flask-wtf = "*" flask-wtf = "*"
en-core-web-sm = {file = "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz"} better-profanity = "*"
[dev-packages] [dev-packages]

28
Pipfile.lock generated
View File

@@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "6edd84812b999051a69550ff223372410e1bd92bcde1f20d547217ff54fbe834" "sha256": "07c5ec537d0ab29e426e899c8762e6a95c7799bba46f01e2280282ab686da5ba"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
@@ -16,6 +16,14 @@
] ]
}, },
"default": { "default": {
"better-profanity": {
"hashes": [
"sha256:8a6fdc8606d7471e7b5f6801917eca98ec211098262e82f62da4f5de3a73145b",
"sha256:bd4c529ea6aa2db1aaa50524be1ed14d0fe5c664f1fd88c8bc388c7e9f9f00e8"
],
"index": "pypi",
"version": "==0.7.0"
},
"blis": { "blis": {
"hashes": [ "hashes": [
"sha256:148f59a0a47a38ce82e3afc50c709494d5e5a494bef28ce1519c7a17346c645b", "sha256:148f59a0a47a38ce82e3afc50c709494d5e5a494bef28ce1519c7a17346c645b",
@@ -69,11 +77,11 @@
}, },
"click": { "click": {
"hashes": [ "hashes": [
"sha256:19a4baa64da924c5e0cd889aba8e947f280309f1a2ce0947a3e3a7bcb7cc72d6", "sha256:5e0d195c2067da3136efb897449ec1e9e6c98282fbf30d7f9e164af9be901a6b",
"sha256:977c213473c7665d3aa092b41ff12063227751c41d7b17165013e10069cc5cd2" "sha256:7ab900e38149c9872376e8f9b5986ddcaf68c0f413cf73678a0bca5547e6f976"
], ],
"markers": "python_version >= '3.7'", "markers": "python_version >= '3.7'",
"version": "==8.1.0" "version": "==8.1.1"
}, },
"colorama": { "colorama": {
"hashes": [ "hashes": [
@@ -129,11 +137,11 @@
}, },
"flask-login": { "flask-login": {
"hashes": [ "hashes": [
"sha256:6d33aef15b5bcead780acc339464aae8a6e28f13c90d8b1cf9de8b549d1c0b4b", "sha256:5cb01ce4dc253967b6ac722a11e46de83b6272ef7a19cc7b5725ae636916d04d",
"sha256:7451b5001e17837ba58945aead261ba425fdf7b4f0448777e597ddab39f4fba0" "sha256:aa84fcfb4c3cf09ca58c08e816b7bce73f1349ba1cf13d00d8dffc5872d5fcf6"
], ],
"index": "pypi", "index": "pypi",
"version": "==0.5.0" "version": "==0.6.0"
}, },
"flask-sqlalchemy": { "flask-sqlalchemy": {
"hashes": [ "hashes": [
@@ -687,10 +695,10 @@
}, },
"wasabi": { "wasabi": {
"hashes": [ "hashes": [
"sha256:152245d892030a3a7b511038e9472acff6d0e237cfe4123fef0d147f2d3274fc", "sha256:217edcb2850993c7931399e7419afccde13539d589e333bc85f9053cf0bb1772",
"sha256:f40f317981d019903db5b69eb2bf78519c9e165c1dfdbd0452e4ca81ff9a31d2" "sha256:ada6f13e9b70ef26bf95fad0febdfdebe2005e29a08ad58f4bbae383a97298cf"
], ],
"version": "==0.9.0" "version": "==0.9.1"
}, },
"werkzeug": { "werkzeug": {
"hashes": [ "hashes": [

View File

@@ -1,8 +1,6 @@
from typing import Optional from typing import Optional
from profanity_filter import ProfanityFilter
from wtforms.validators import ValidationError from wtforms.validators import ValidationError
from better_profanity import profanity
pf = ProfanityFilter()
class NoProfanity(object): class NoProfanity(object):
@@ -12,5 +10,5 @@ class NoProfanity(object):
self.message = message self.message = message
def __call__(self, form, field): def __call__(self, form, field):
if pf.is_profane(field.data): if profanity.contains_profanity(field.data):
raise ValidationError(self.message) raise ValidationError(self.message)