Switched json parser to improve encoding/decoding times.
This commit is contained in:
parent
c61cd505af
commit
836fa49b0d
@ -1,12 +1,7 @@
|
|||||||
Flask==0.10.1
|
requests
|
||||||
Flask-Login==0.3.1
|
wtforms
|
||||||
Flask-SQLAlchemy==2.0
|
flask
|
||||||
Flask-WTF==0.12
|
flask-login
|
||||||
itsdangerous==0.24
|
flask-sqlalchemy
|
||||||
Jinja2==2.8
|
flask-wtf
|
||||||
MarkupSafe==0.23
|
ujson
|
||||||
requests==2.8.0
|
|
||||||
SQLAlchemy==1.0.8
|
|
||||||
Werkzeug==0.10.4
|
|
||||||
wheel==0.24.0
|
|
||||||
WTForms==2.0.2
|
|
@ -1,4 +1,4 @@
|
|||||||
import json
|
import ujson as json
|
||||||
import re
|
import re
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class User(db.Model):
|
|||||||
self.username = data['user_information']['username']
|
self.username = data['user_information']['username']
|
||||||
self.gravatar = data['user_information']['gravatar']
|
self.gravatar = data['user_information']['gravatar']
|
||||||
if data.get('requested_information'):
|
if data.get('requested_information'):
|
||||||
self.radicals = json.dumps(data['requested_information'])
|
self.radicals = json.dumps(data['requested_information'], ensure_ascii=False)
|
||||||
|
|
||||||
def parse_kanji(self):
|
def parse_kanji(self):
|
||||||
response = requests.get("https://www.wanikani.com/api/user/" + self.api_key + "/kanji/")
|
response = requests.get("https://www.wanikani.com/api/user/" + self.api_key + "/kanji/")
|
||||||
@ -71,7 +71,7 @@ class User(db.Model):
|
|||||||
if data.get('error'):
|
if data.get('error'):
|
||||||
raise ValueError(data['error']['message'])
|
raise ValueError(data['error']['message'])
|
||||||
if data.get('requested_information'):
|
if data.get('requested_information'):
|
||||||
self.kanji = json.dumps(data['requested_information'])
|
self.kanji = json.dumps(data['requested_information'], ensure_ascii=False)
|
||||||
|
|
||||||
def parse_vocabulary(self):
|
def parse_vocabulary(self):
|
||||||
response = requests.get("https://www.wanikani.com/api/user/" + self.api_key + "/vocabulary/")
|
response = requests.get("https://www.wanikani.com/api/user/" + self.api_key + "/vocabulary/")
|
||||||
@ -80,7 +80,7 @@ class User(db.Model):
|
|||||||
if data.get('error'):
|
if data.get('error'):
|
||||||
raise ValueError(data['error']['message'])
|
raise ValueError(data['error']['message'])
|
||||||
if data.get('requested_information'):
|
if data.get('requested_information'):
|
||||||
self.vocabulary = json.dumps(data['requested_information']['general'])
|
self.vocabulary = json.dumps(data['requested_information']['general'], ensure_ascii=False)
|
||||||
|
|
||||||
def update_all(self):
|
def update_all(self):
|
||||||
if (datetime.utcnow() - self.last_updated) > timedelta(hours=1):
|
if (datetime.utcnow() - self.last_updated) > timedelta(hours=1):
|
||||||
|
Loading…
Reference in New Issue
Block a user