Renaming definitions to glossary
Former-commit-id: fc5361ee49f6f74a2032f56d1d13728eecb7b8c8
This commit is contained in:
parent
c43d1da885
commit
89f407e9fa
@ -34,11 +34,11 @@ class Dictionary:
|
||||
cursor.execute('SELECT * FROM Terms WHERE expression {0} ? OR reading=?'.format('LIKE' if partial else '='), (word, word))
|
||||
|
||||
results = list()
|
||||
for expression, reading, definitions, tags in cursor.fetchall():
|
||||
for expression, reading, glossary, tags in cursor.fetchall():
|
||||
results.append({
|
||||
'expression': expression,
|
||||
'reading': reading,
|
||||
'definitions': definitions,
|
||||
'glossary': glossary,
|
||||
'tags': tags.split()
|
||||
})
|
||||
|
||||
@ -51,12 +51,12 @@ class Dictionary:
|
||||
|
||||
query = cursor.fetchone()
|
||||
if query is not None:
|
||||
character, kunyomi, onyomi, meanings = result
|
||||
character, kunyomi, onyomi, glossary = query
|
||||
return {
|
||||
'character': character,
|
||||
'kunyomi': kunyomi,
|
||||
'onyomi': onyomi,
|
||||
'meanings': meanings
|
||||
'glossary': glossary
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,17 +54,17 @@ class Translator:
|
||||
root = root or source
|
||||
|
||||
for entry in self.dictionary.findTerm(root, partial):
|
||||
key = entry['expression'], entry['reading'], entry['definitions']
|
||||
key = entry['expression'], entry['reading'], entry['glossary']
|
||||
if key not in groups:
|
||||
groups[key] = entry, source, rules
|
||||
|
||||
|
||||
def formatResult(self, group):
|
||||
(expression, reading, definition), (entry, source, rules) = group
|
||||
(expression, reading, glossary), (entry, source, rules) = group
|
||||
return {
|
||||
'expression': expression,
|
||||
'reading': reading,
|
||||
'definitions': definition,
|
||||
'glossary': glossary,
|
||||
'rules': rules,
|
||||
'source': source
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2011 Alex Yatskov
|
||||
# Copyright (C) 2013 Alex Yatskov
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -252,14 +252,14 @@ class MainWindowReader(QtGui.QMainWindow, reader_ui.Ui_MainWindowReader):
|
||||
markup = reader_util.buildFactMarkupExpression(
|
||||
definition['expression'],
|
||||
definition['reading'],
|
||||
definition['definitions'],
|
||||
definition['glossary'],
|
||||
definition['sentence']
|
||||
)
|
||||
self.ankiAddFact(markup)
|
||||
if command == 'addReading':
|
||||
markup = reader_util.buildFactMarkupReading(
|
||||
definition['reading'],
|
||||
definition['definitions'],
|
||||
definition['glossary'],
|
||||
definition['sentence']
|
||||
)
|
||||
self.ankiAddFact(markup)
|
||||
|
@ -95,20 +95,20 @@ def replaceMarkupInFields(fields, markup):
|
||||
return result
|
||||
|
||||
|
||||
def buildFactMarkupExpression(expression, reading, definitions, sentence=None):
|
||||
def buildFactMarkupExpression(expression, reading, glossary, sentence=None):
|
||||
return {
|
||||
'%e': expression,
|
||||
'%r': reading,
|
||||
'%g': definitions,
|
||||
'%g': glossary,
|
||||
'%s': sentence
|
||||
}
|
||||
|
||||
|
||||
def buildFactMarkupReading(reading, definitions, sentence=None):
|
||||
def buildFactMarkupReading(reading, glossary, sentence=None):
|
||||
return {
|
||||
'%e': reading,
|
||||
'%r': None,
|
||||
'%g': definitions,
|
||||
'%g': glossary,
|
||||
'%s': sentence
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ def copyDefinitions(definitions):
|
||||
|
||||
for definition in definitions:
|
||||
if definition['reading']:
|
||||
text += u'{expression}\t{reading}\t{definitions}\n'.format(**definition)
|
||||
text += u'{expression}\t{reading}\t{glossary}\n'.format(**definition)
|
||||
else:
|
||||
text += u'{expression}\t{meanings}\n'.format(**definition)
|
||||
|
||||
@ -149,9 +149,9 @@ def buildDefinitionHtml(definition, factIndex, factQuery):
|
||||
|
||||
links = '<a href = "copyDefinition:{0}"><img src = "://img/img/icon_copy_definition.png" align = "right"/></a>'.format(factIndex)
|
||||
if factQuery:
|
||||
if factQuery(buildFactMarkupExpression(definition['expression'], definition['reading'], definition['definitions'])):
|
||||
if factQuery(buildFactMarkupExpression(definition['expression'], definition['reading'], definition['glossary'])):
|
||||
links += '<a href = "addExpression:{0}"><img src = "://img/img/icon_add_expression.png" align = "right"/></a>'.format(factIndex)
|
||||
if factQuery(buildFactMarkupReading(definition['reading'], definition['definitions'])):
|
||||
if factQuery(buildFactMarkupReading(definition['reading'], definition['glossary'])):
|
||||
links += '<a href = "addReading:{0}"><img src = "://img/img/icon_add_reading.png" align = "right"/></a>'.format(factIndex)
|
||||
|
||||
html = u"""
|
||||
@ -159,7 +159,7 @@ def buildDefinitionHtml(definition, factIndex, factQuery):
|
||||
<span class = "expression">{1} {2}<br/></span>
|
||||
<span class = "glossary">{3}<br/></span>
|
||||
<span class = "conjugations">{4}</span>
|
||||
<br clear = "all"/>""".format(links, definition['expression'], reading, definition['definitions'], conjugations)
|
||||
<br clear = "all"/>""".format(links, definition['expression'], reading, definition['glossary'], conjugations)
|
||||
|
||||
return html
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user