Moves the clean method to misc.py, moves misc.py

This commit is contained in:
Oleg Silkin 2020-03-27 17:44:22 -04:00
parent 644e5e8477
commit 63f2c7e9e0
4 changed files with 12 additions and 11 deletions

View file

@ -1,14 +1,15 @@
import json
import time
import logging
import math
import timeit
import typing
from peewee import ModelSelect
from playhouse.shortcuts import model_to_dict
from peewee import *
import nacl.hash
from src.server.validation import is_valid_base_comment
from src.misc import clean
def get_database_connection():
@ -125,10 +126,6 @@ def comment_list(claim_id: str = None, parent_id: str = None,
return data
def clean(thing: dict) -> dict:
return {k: v for k, v in thing.items() if v is not None}
def get_comment(comment_id: str) -> dict:
return (comment_list(expressions=(Comment.comment_id == comment_id), page_size=1)
.get('items')

View file

@ -7,7 +7,7 @@ from src.server.validation import is_valid_base_comment
from src.server.validation import is_valid_credential_input
from src.server.validation import validate_signature_from_claim
from src.server.validation import body_is_valid
from src.server.misc import get_claim_from_id
from src.misc import get_claim_from_id
from src.server.external import send_notifications
from src.server.external import send_notification
import src.database.queries as db

View file

@ -20,3 +20,7 @@ def clean_input_params(kwargs: dict):
kwargs[k] = v.strip()
if k in ID_LIST:
kwargs[k] = v.lower()
def clean(thing: dict) -> dict:
return {k: v for k, v in thing.items() if v is not None}

View file

@ -9,7 +9,7 @@ import src.database.queries as db
from src.database.writes import abandon_comment, create_comment
from src.database.writes import hide_comments
from src.database.writes import edit_comment
from src.server.misc import clean_input_params
from src.misc import clean_input_params
from src.server.errors import make_error, report_error
logger = logging.getLogger(__name__)