Use single quotes throughout the code, remove braces around conditions and remove json.dumps where not needed
This commit is contained in:
parent
3f5dbe904b
commit
5ec3df733e
@ -435,59 +435,59 @@ class AnkiBridge:
|
|||||||
|
|
||||||
|
|
||||||
def getNextCard(self):
|
def getNextCard(self):
|
||||||
if (self.window().reviewer.card is None) or (self.window().state != "review"):
|
if self.window().reviewer.card is None or self.window().state != 'review':
|
||||||
self.window().moveToState('review')
|
self.window().moveToState('review')
|
||||||
|
|
||||||
card = self.window().reviewer.card
|
card = self.window().reviewer.card
|
||||||
nextCard = {}
|
return {
|
||||||
nextCard['id'] = card.id
|
'success': True,
|
||||||
nextCard['question'] = card._getQA()['q']
|
'id': card.id,
|
||||||
nextCard['answer'] = card._getQA()['a']
|
'question': card._getQA()['q'],
|
||||||
nextCard['answerButtons'] = self.window().reviewer._answerButtonList()
|
'answer': card._getQA()['a'],
|
||||||
nextCard['model_name'] = card.note(reload)._model['name']
|
'answerButtons': self.window().reviewer._answerButtonList(),
|
||||||
nextCard['ord'] = card.ord
|
'modelName': card.note(reload)._model['name'],
|
||||||
nextCard['fields'] = json.dumps(card.note(reload).fields)
|
'ord': card.ord,
|
||||||
nextCard['_fmap'] = card.note(reload)._fmap
|
'fields': card.note(reload).fields,
|
||||||
nextCard['success'] = True
|
'fieldMap': card.note(reload)._fmap
|
||||||
return json.dumps(nextCard)
|
}
|
||||||
|
|
||||||
|
|
||||||
def showQuestion(self):
|
def showQuestion(self):
|
||||||
if (self.window().reviewer.card is None) or (self.window().state != "review"):
|
if self.window().reviewer.card is None or self.window().state != 'review':
|
||||||
self.window().moveToState('review')
|
self.window().moveToState('review')
|
||||||
|
|
||||||
self.window().reviewer._showQuestion()
|
self.window().reviewer._showQuestion()
|
||||||
return json.dumps({'success': True})
|
return {'success': True}
|
||||||
|
|
||||||
|
|
||||||
def showAnswer(self):
|
def showAnswer(self):
|
||||||
if self.window().reviewer.mw.state != "review":
|
if self.window().reviewer.mw.state != 'review':
|
||||||
return json.dumps({'success': False, 'message': 'Window state is not review.'})
|
return {'success': False, 'message': 'Window state is not review.'}
|
||||||
else:
|
else:
|
||||||
self.window().reviewer._showAnswer()
|
self.window().reviewer._showAnswer()
|
||||||
return json.dumps({'success': True})
|
return {'success': True}
|
||||||
|
|
||||||
|
|
||||||
def answerCard(self, id, ease):
|
def answerCard(self, id, ease):
|
||||||
if self.window().reviewer.mw.state != "review":
|
if self.window().reviewer.mw.state != 'review':
|
||||||
return json.dumps({'success': False, 'message': 'Window state is not review.'})
|
return {'success': False, 'message': 'Window state is not review.'}
|
||||||
elif self.window().reviewer.state != "answer":
|
elif self.window().reviewer.state != 'answer':
|
||||||
return json.dumps({'success': False, 'message': 'Reviewer state is not answer.'})
|
return {'success': False, 'message': 'Reviewer state is not answer.'}
|
||||||
elif self.window().reviewer.card.id != id:
|
elif self.window().reviewer.card.id != id:
|
||||||
return json.dumps({'success': False, 'message': 'Given card does not match.'})
|
return {'success': False, 'message': 'Given card does not match.'}
|
||||||
elif self.window().col.sched.answerButtons(self.window().reviewer.card) < ease:
|
elif self.window().col.sched.answerButtons(self.window().reviewer.card) < ease:
|
||||||
return json.dumps({'success': False, 'message': 'Invalid ease provided.'})
|
return {'success': False, 'message': 'Invalid ease provided.'}
|
||||||
else:
|
else:
|
||||||
self.window().reviewer._answerCard(ease)
|
self.window().reviewer._answerCard(ease)
|
||||||
return json.dumps({'success': True})
|
return {'success': True}
|
||||||
|
|
||||||
|
|
||||||
def checkState(self):
|
def checkState(self):
|
||||||
stateInfo = {}
|
return {
|
||||||
stateInfo['success'] = True
|
'success': True,
|
||||||
stateInfo['window_state'] = self.window().state
|
'window_state': self.window().state,
|
||||||
stateInfo['reviewer_state'] = self.window().reviewer.state
|
'reviewer_state': self.window().reviewer.state
|
||||||
return json.dumps(stateInfo)
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user