From 5a16579fe39e3fb62ba66340f7a689ec2c879a47 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 2 Apr 2020 22:43:20 -0700 Subject: [PATCH] Add a 'type' string to all etiquette jsonify outputs. --- etiquette/jsonify.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etiquette/jsonify.py b/etiquette/jsonify.py index d1bb5ba..5105ae1 100644 --- a/etiquette/jsonify.py +++ b/etiquette/jsonify.py @@ -5,6 +5,7 @@ dictionaries suitable for JSON serializing. def album(a, minimal=False): j = { + 'type': 'album', 'id': a.id, 'description': a.description, 'title': a.title, @@ -19,6 +20,7 @@ def album(a, minimal=False): def bookmark(b): j = { + 'type': 'bookmark', 'id': b.id, 'author': user_or_none(b.get_author()), 'url': b.url, @@ -28,6 +30,7 @@ def bookmark(b): def exception(e): j = { + 'type': 'error', 'error_type': e.error_type, 'error_message': e.error_message, } @@ -37,6 +40,7 @@ def photo(p, include_albums=True, include_tags=True): tags = p.get_tags() tags.sort(key=lambda x: x.name) j = { + 'type': 'photo', 'id': p.id, 'author': user_or_none(p.get_author()), 'extension': p.extension, @@ -64,6 +68,7 @@ def photo(p, include_albums=True, include_tags=True): def tag(t, include_synonyms=False, minimal=False): j = { + 'type': 'tag', 'id': t.id, 'name': t.name, } @@ -78,6 +83,7 @@ def tag(t, include_synonyms=False, minimal=False): def user(u): j = { + 'type': 'user', 'id': u.id, 'username': u.username, 'created': u.created,