diff --git a/activitypub.py b/activitypub.py index 673d726..a79bf90 100644 --- a/activitypub.py +++ b/activitypub.py @@ -1,7 +1,6 @@ """Handles requests for ActivityPub endpoints: actors, inbox, etc. """ import datetime -import json import logging import appengine_config @@ -11,6 +10,7 @@ from granary import as2, microformats2 import mf2util from oauth_dropins.webutil import util from oauth_dropins.webutil.handlers import memcache_response +import ujson as json import webapp2 import common diff --git a/app.yaml b/app.yaml index 948368c..d4ecac0 100644 --- a/app.yaml +++ b/app.yaml @@ -19,6 +19,8 @@ libraries: version: latest - name: ssl version: latest +- name: ujson + version: latest - name: webob version: latest diff --git a/common.py b/common.py index 23d9e79..d33ebc9 100644 --- a/common.py +++ b/common.py @@ -3,7 +3,6 @@ """ from __future__ import unicode_literals import itertools -import json import logging import re import urlparse @@ -11,6 +10,7 @@ import urlparse from granary import as2 from oauth_dropins.webutil import handlers, util import requests +import ujson as json from webmentiontools import send from webob import exc diff --git a/redirect.py b/redirect.py index 7965f2a..a8659a2 100644 --- a/redirect.py +++ b/redirect.py @@ -9,13 +9,13 @@ https://github.com/snarfed/bridgy-fed/issues/16#issuecomment-424799599 https://github.com/tootsuite/mastodon/pull/6219#issuecomment-429142747 """ import datetime -import json import logging from granary import as2, microformats2 import mf2util from oauth_dropins.webutil import util from oauth_dropins.webutil.handlers import memcache_response +import ujson as json import webapp2 import appengine_config diff --git a/render.py b/render.py index b71d009..7c47d4e 100644 --- a/render.py +++ b/render.py @@ -1,13 +1,13 @@ # coding=utf-8 """Renders mf2 proxy pages based on stored Responses.""" import datetime -import json import appengine_config from granary import as2, atom, microformats2 from oauth_dropins.webutil.handlers import memcache_response, ModernHandler from oauth_dropins.webutil import util +import ujson as json import webapp2 from models import Response diff --git a/requirements.freeze.txt b/requirements.freeze.txt index 33a1991..5b0a486 100644 --- a/requirements.freeze.txt +++ b/requirements.freeze.txt @@ -53,6 +53,7 @@ soupsieve==1.9.4 testtools==2.3.0 traceback2==1.4.0 tweepy==3.8.0 +ujson==1.35 unittest2==1.1.0 uritemplate==3.0.0 urllib3==1.25.6 diff --git a/requirements.txt b/requirements.txt index 9e2d22a..97e4e2d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,4 +12,5 @@ mox3>=0.24.0 pycrypto requests==2.10.0 requests-toolbelt==0.6.2 +ujson>=1.35 urllib3>=1.14 diff --git a/tests/test_activitypub.py b/tests/test_activitypub.py index 411e6de..c066261 100644 --- a/tests/test_activitypub.py +++ b/tests/test_activitypub.py @@ -5,13 +5,13 @@ TODO: test error handling """ from __future__ import unicode_literals import copy -import json import urllib from mock import call, patch from oauth_dropins.webutil import util from oauth_dropins.webutil.testutil import requests_response import requests +import ujson as json import activitypub from activitypub import app diff --git a/tests/test_common.py b/tests/test_common.py index 2068b9c..6653a9e 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,13 +1,13 @@ # coding=utf-8 """Unit tests for common.py.""" from __future__ import unicode_literals -import json import logging import mock from oauth_dropins.webutil import util from oauth_dropins.webutil.testutil import requests_response import requests +import ujson as json from webob import exc import common diff --git a/tests/test_render.py b/tests/test_render.py index 710744a..1af080a 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -1,7 +1,8 @@ # coding=utf-8 """Unit tests for render.py.""" from __future__ import unicode_literals -import json + +import ujson as json from models import Response import testutil diff --git a/tests/test_webfinger.py b/tests/test_webfinger.py index 43f1993..cc91545 100644 --- a/tests/test_webfinger.py +++ b/tests/test_webfinger.py @@ -4,13 +4,13 @@ TODO: test error handling """ from __future__ import unicode_literals -import json import urllib import mock from oauth_dropins.webutil import util from oauth_dropins.webutil.testutil import requests_response import requests +import ujson as json import common import models diff --git a/tests/test_webmention.py b/tests/test_webmention.py index 9514b47..8558051 100644 --- a/tests/test_webmention.py +++ b/tests/test_webmention.py @@ -5,7 +5,6 @@ TODO: test error handling """ from __future__ import unicode_literals import copy -import json import urllib import urllib2 @@ -18,6 +17,7 @@ from mock import call from oauth_dropins.webutil import util from oauth_dropins.webutil.testutil import requests_response import requests +import ujson as json import activitypub from common import ( diff --git a/webfinger.py b/webfinger.py index b35e2f9..bac61d7 100644 --- a/webfinger.py +++ b/webfinger.py @@ -12,7 +12,6 @@ TODO: test: """ from __future__ import unicode_literals import datetime -import json import logging import urllib import urlparse @@ -21,6 +20,7 @@ import appengine_config import mf2util from oauth_dropins.webutil import handlers, util +import ujson as json import webapp2 import common diff --git a/webmention.py b/webmention.py index 0cae3c7..ff53049 100644 --- a/webmention.py +++ b/webmention.py @@ -4,7 +4,6 @@ TODO tests: * actor/attributedTo could be string URL * salmon rel via webfinger via author.name + domain """ -import json import logging import urllib import urlparse @@ -20,6 +19,7 @@ from granary import as2, atom, microformats2, source import mf2util from oauth_dropins.webutil import util import requests +import ujson as json import webapp2 from webob import exc @@ -256,8 +256,7 @@ class WebmentionHandler(webapp2.RequestHandler): feed = common.requests_get(atom_url).text parsed = feedparser.parse(feed) - logging.info('Parsed: %s', json.dumps(parsed, indent=2, - default=lambda key: '-')) + logging.info('Parsed: %s', json.dumps(parsed, indent=2)) entry = parsed.entries[0] target_id = entry.id in_reply_to = self.source_obj.get('inReplyTo')