diff --git a/files/classes/comment.py b/files/classes/comment.py index d06c06bc6..4ef281954 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -85,12 +85,12 @@ class Comment(Base): @property @lazy def options(self): - return tuple(x for x in self.child_comments if x.author_id == AUTOPOLLER_ID) + return [x for x in self.child_comments if x.author_id == AUTOPOLLER_ID] @property @lazy def choices(self): - return tuple(x for x in self.child_comments if x.author_id == AUTOCHOICE_ID) + return [x for x in self.child_comments if x.author_id == AUTOCHOICE_ID] def total_poll_voted(self, v): if v: @@ -100,7 +100,7 @@ class Comment(Base): def total_choice_voted(self, v): if v: - return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_(tuple(x.id for x in self.choices))).all() + return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).all() return False @property diff --git a/files/classes/submission.py b/files/classes/submission.py index 597878e78..760dc4181 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -107,7 +107,7 @@ class Submission(Base): def total_choice_voted(self, v): if v and self.choices: - return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_(tuple(x.id for x in self.choices))).all() + return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).all() return False def total_bet_voted(self, v): @@ -221,8 +221,8 @@ class Submission(Base): if self.club: return link output = self.title.lower() - output = re.sub('&\w{2,3};', '', output, re.A) - output = [re.sub('\W', '', word, re.A) for word in output.split()] + output = re.sub('&\w{2,3};', '', output, flags=re.A) + output = [re.sub('\W', '', word, flags=re.A) for word in output.split()] output = [x for x in output if x][:6] output = '-'.join(output) if not output: output = '-' diff --git a/files/classes/user.py b/files/classes/user.py index 9de72f263..a841ce5cb 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -163,7 +163,7 @@ class User(Base): @property @lazy def all_blocks(self): - return tuple(x[0] for x in g.db.query(SubBlock.sub).filter_by(user_id=self.id).all()) + return [x[0] for x in g.db.query(SubBlock.sub).filter_by(user_id=self.id).all()] @lazy def blocks(self, sub): @@ -214,7 +214,7 @@ class User(Base): @property @lazy def paid_dues(self): - return self.admin_level or self.club_allowed or self.patron > 1 or (self.patron == 1 and self.truecoins > dues/10) or (self.club_allowed != False and self.truecoins > dues) + return self.admin_level or self.club_allowed or self.patron > 1 or (self.patron == 1 and self.truecoins > dues/5) or (self.club_allowed != False and self.truecoins > dues) @lazy def any_block_exists(self, other): diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index daa3fd543..f995b53f3 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -67,7 +67,7 @@ def NOTIFY_USERS(text, v): if id == 0: continue if word in text.lower() and id not in notify_users and v.id != id: notify_users.add(id) - soup = BeautifulSoup(text, 'html.parser') + soup = BeautifulSoup(text, 'lxml') for mention in soup.find_all("a", href=re.compile("^\/id\/([0-9]+)")): id = int(mention["href"].split("/id/")[1]) if id != v.id: @@ -82,7 +82,7 @@ def NOTIFY_USERS2(text, v): if id == 0: continue if word in text.lower() and id not in notify_users and v.id != id: notify_users.add(id) - for i in re.finditer("(^|\s|\n)@((\w|-){1,25})", text, re.A): + for i in re.finditer("(^|\s|\n)@((\w|-){1,25})", text, flags=re.A): user = get_user(i.group(2), graceful=True) if user and not v.any_block_exists(user): notify_users.add(user.id) diff --git a/files/helpers/const.py b/files/helpers/const.py index 4524fd9ac..28dad95f6 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -106,8 +106,8 @@ SLURS = { single_words = "|".join([slur.lower() for slur in SLURS.keys()]) -SLUR_REGEX = re.compile(rf"((?<=\s|>)|^)({single_words})((?=[\s<,.$]|s[\s<,.$]))", re.I|re.A) -SLUR_REGEX_UPPER = re.compile(rf"((?<=\s|>)|^)({single_words.upper()})((?=[\s<,.$]|S[\s<,.$]))", re.A) +SLUR_REGEX = re.compile(rf"((?<=\s|>)|^)({single_words})((?=[\s<,.$]|s[\s<,.$]))", flags=re.I|re.A) +SLUR_REGEX_UPPER = re.compile(rf"((?<=\s|>)|^)({single_words.upper()})((?=[\s<,.$]|S[\s<,.$]))", flags=re.A) def sub_matcher(match): return SLURS[match.group(0).lower()] @@ -125,8 +125,8 @@ def torture_ap(body, username): body = SLUR_REGEX_UPPER.sub(sub_matcher_upper, body) body = SLUR_REGEX.sub(sub_matcher, body) for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) - body = re.sub('(^|\s|\n)(i|me) ', rf'\1@{username} ', body, re.I|re.A) - body = re.sub("(^|\s|\n)i'm ", rf'\1@{username} is ', body, re.I|re.A) + body = re.sub('(^|\s|\n)(i|me) ', rf'\1@{username} ', body, flags=re.I|re.A) + body = re.sub("(^|\s|\n)i'm ", rf'\1@{username} is ', body, flags=re.I|re.A) return body diff --git a/files/helpers/filters.py b/files/helpers/filters.py index 0b9f70f12..f6d1ecff8 100644 --- a/files/helpers/filters.py +++ b/files/helpers/filters.py @@ -5,7 +5,7 @@ from files.classes import BannedDomain def filter_comment_html(html_text): - soup = BeautifulSoup(html_text, 'html.parser') + soup = BeautifulSoup(html_text, 'lxml') links = soup.find_all("a") @@ -28,7 +28,7 @@ def filter_comment_html(html_text): new_domain += "." + parts[j] domain_list.add(new_domain) - bans = tuple(x for x in g.db.query(BannedDomain).filter(BannedDomain.domain.in_(list(domain_list))).all()) + bans = [x for x in g.db.query(BannedDomain).filter(BannedDomain.domain.in_(list(domain_list))).all()] if bans: return bans else: return [] diff --git a/files/helpers/get.py b/files/helpers/get.py index 0d2fbed44..76f2140e3 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -140,8 +140,6 @@ def get_posts(pids, v=None): if not pids: return [] - pids=tuple(pids) - if v: vt = g.db.query(Vote).filter( Vote.submission_id.in_(pids), @@ -218,8 +216,6 @@ def get_comments(cids, v=None, load_parent=False): if not cids: return [] - cids=tuple(cids) - if v: votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery() @@ -282,8 +278,6 @@ def get_domain(s): domain_list.add(new_domain) - domain_list = tuple(list(domain_list)) - doms = [x for x in g.db.query(BannedDomain).filter(BannedDomain.domain.in_(domain_list)).all()] if not doms: diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 8ba32540a..2fa0b86c9 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -12,7 +12,7 @@ import signal import time db = db_session() -marseys = tuple(x[0] for x in db.query(Marsey.name).all()) +marseys = [x[0] for x in db.query(Marsey.name).all()] + ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','exclamationpoint','period','questionmark'] db.close() allowed_tags = tags = ['b', @@ -120,16 +120,16 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): sanitized = sanitized.replace("\ufeff", "").replace("𒐪","").replace(" \ No newline at end of file + \ No newline at end of file diff --git a/files/templates/marseys.html b/files/templates/marseys.html index e78708344..2f4206d35 100644 --- a/files/templates/marseys.html +++ b/files/templates/marseys.html @@ -20,7 +20,7 @@