1
This commit is contained in:
Alex Yatskov 2016-05-17 22:12:05 -07:00
parent 64a32a0739
commit a8f784f0a4
5 changed files with 19 additions and 19 deletions

View File

@ -59,7 +59,7 @@ class Translator:
return definitions, length
def findCharacters(self, text):
def findKanji(self, text):
text = util.sanitize(text, kana=False)
processed = {}

View File

@ -53,7 +53,7 @@ def sanitize(text, kana=True, wildcards=False):
else:
overrides = list()
result = unicode()
result = u''
for c in text:
if checker(c) or c in overrides:
result += c

View File

@ -89,8 +89,8 @@ class DialogPreferences(QtGui.QDialog, gen.preferences_ui.Ui_DialogPreferences):
def profileToDialog(self):
profile, name = self.activeProfile()
deck = unicode() if profile is None else profile['deck']
model = unicode() if profile is None else profile['model']
deck = u'' if profile is None else profile['deck']
model = u'' if profile is None else profile['model']
self.comboBoxDeck.blockSignals(True)
self.comboBoxDeck.clear()
@ -141,7 +141,7 @@ class DialogPreferences(QtGui.QDialog, gen.preferences_ui.Ui_DialogPreferences):
itemName.setFlags(QtCore.Qt.ItemIsSelectable)
columns.append(itemName)
itemValue = QtGui.QTableWidgetItem(fieldsPrefs.get(name, unicode()))
itemValue = QtGui.QTableWidgetItem(fieldsPrefs.get(name, u''))
columns.append(itemValue)
for j, column in enumerate(columns):

View File

@ -30,8 +30,8 @@ import updates
class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
class State:
def __init__(self):
self.filename = unicode()
self.searchText = unicode()
self.filename = u''
self.searchText = u''
self.kanjiDefs = []
self.vocabDefs = []
self.scanPosition = 0
@ -298,13 +298,13 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
self.state.vocabDefs, length = self.language.findTerm(text, True)
self.updateVocabDefs()
if self.dockKanji.isVisible():
self.state.kanjiDefs = self.language.findCharacters(text)
self.state.kanjiDefs = self.language.findKanji(text)
self.updateKanjiDefs()
def onKanjiDefSearchReturn(self):
text = unicode(self.textKanjiSearch.text())
self.state.kanjiDefs = self.language.findCharacters(text)
self.state.kanjiDefs = self.language.findKanji(text)
self.updateKanjiDefs()
@ -376,7 +376,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
self.preferences['textContent'] = unicode(self.textContent.toPlainText())
self.setWindowTitle('Yomichan')
self.textContent.setPlainText(unicode())
self.textContent.setPlainText(u'')
self.updateRecentFile(False)
self.state = self.State()
@ -493,7 +493,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
content = unicode(self.textContent.toPlainText())
contentSample = content[samplePosStart:samplePosEnd]
contentSampleFlat = contentSample.replace(u'\n', unicode())
contentSampleFlat = contentSample.replace(u'\n', u'')
cursor = self.textContent.textCursor()
@ -512,11 +512,11 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
if self.dockKanji.isVisible():
if lengthMatched == 0:
self.state.kanjiDefs = self.language.findCharacters(contentSampleFlat[0])
self.state.kanjiDefs = self.language.findKanji(contentSampleFlat[0])
if len(self.state.kanjiDefs) > 0:
lengthMatched = 1
else:
self.state.kanjiDefs = self.language.findCharacters(contentSampleFlat[:lengthMatched])
self.state.kanjiDefs = self.language.findKanji(contentSampleFlat[:lengthMatched])
self.updateKanjiDefs()
lengthSelect = 0
@ -595,7 +595,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
self.state.vocabDefs += self.language.dictionary.findTerm(word)
if self.dockKanji.isVisible():
self.state.kanjiDefs += self.language.findCharacters(word)
self.state.kanjiDefs += self.language.findKanji(word)
self.updateVocabDefs(scroll=True)
self.updateKanjiDefs(scroll=True)

View File

@ -37,7 +37,7 @@ def decodeContent(content):
def stripReadings(content):
return re.sub(u'《[^》]+》', unicode(), content)
return re.sub(u'《[^》]+》', u'', content)
def findSentence(content, position):
@ -105,7 +105,7 @@ def markupVocabExp(definition):
return {
'expression': definition['expression'],
'reading': definition['reading'] or unicode(),
'reading': definition['reading'] or u'',
'glossary': definition['glossary'],
'sentence': definition.get('sentence'),
'summary': summary
@ -116,7 +116,7 @@ def markupVocabReading(definition):
if definition['reading']:
return {
'expression': definition['reading'],
'reading': unicode(),
'reading': u'',
'glossary': definition['glossary'],
'sentence': definition.get('sentence'),
'summary': definition['reading']
@ -170,11 +170,11 @@ def buildEmpty():
def buildVocabDef(definition, index, query):
reading = unicode()
reading = u''
if definition['reading']:
reading = u'<span class="reading">[{0}]<br></span>'.format(definition['reading'])
rules = unicode()
rules = u''
if definition.get('rules'):
rules = ' &lt; '.join(definition['rules'])
rules = '<span class="rules">({0})<br></span>'.format(rules)