diff options
| author | rr- | 2016-05-10 11:56:24 +0200 |
|---|---|---|
| committer | rr- | 2016-05-10 12:15:05 +0200 |
| commit | cd15cdff7a399160113269b8ee70d62272329318 (patch) | |
| tree | 9ffe4412980cb13d01df89ab80f6a0df472455f6 /server/szurubooru/func/util.py | |
| parent | f140ae6176284a6baa65b9bc2adfe2e3bd783f9f (diff) | |
server/scores+favorites: merge duplicate code
Diffstat (limited to 'server/szurubooru/func/util.py')
| -rw-r--r-- | server/szurubooru/func/util.py | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/server/szurubooru/func/util.py b/server/szurubooru/func/util.py index a80485d..f19e7fc 100644 --- a/server/szurubooru/func/util.py +++ b/server/szurubooru/func/util.py @@ -1,7 +1,6 @@ import datetime import hashlib import re -from sqlalchemy.inspection import inspect from szurubooru.errors import ValidationError def unalias_dict(input_dict): @@ -23,29 +22,6 @@ def get_md5(source): def flip(source): return {v: k for k, v in source.items()} -def get_resource_info(entity): - serializers = { - 'tag': lambda tag: tag.first_name, - 'tag_category': lambda category: category.name, - 'comment': lambda comment: comment.comment_id, - 'post': lambda post: post.post_id, - } - - resource_type = entity.__table__.name - assert resource_type in serializers - - primary_key = inspect(entity).identity - assert primary_key is not None - assert len(primary_key) == 1 - - resource_repr = serializers[resource_type](entity) - assert resource_repr - - resource_id = primary_key[0] - assert resource_id - - return (resource_type, resource_id, resource_repr) - def is_valid_email(email): ''' Return whether given email address is valid or empty. ''' return not email or re.match(r'^[^@]*@[^@]*\.[^@]*$', email) |