Cleanup
This commit is contained in:
parent
64a32a0739
commit
a8f784f0a4
@ -59,7 +59,7 @@ class Translator:
|
|||||||
return definitions, length
|
return definitions, length
|
||||||
|
|
||||||
|
|
||||||
def findCharacters(self, text):
|
def findKanji(self, text):
|
||||||
text = util.sanitize(text, kana=False)
|
text = util.sanitize(text, kana=False)
|
||||||
|
|
||||||
processed = {}
|
processed = {}
|
||||||
|
@ -53,7 +53,7 @@ def sanitize(text, kana=True, wildcards=False):
|
|||||||
else:
|
else:
|
||||||
overrides = list()
|
overrides = list()
|
||||||
|
|
||||||
result = unicode()
|
result = u''
|
||||||
for c in text:
|
for c in text:
|
||||||
if checker(c) or c in overrides:
|
if checker(c) or c in overrides:
|
||||||
result += c
|
result += c
|
||||||
|
@ -89,8 +89,8 @@ class DialogPreferences(QtGui.QDialog, gen.preferences_ui.Ui_DialogPreferences):
|
|||||||
def profileToDialog(self):
|
def profileToDialog(self):
|
||||||
profile, name = self.activeProfile()
|
profile, name = self.activeProfile()
|
||||||
|
|
||||||
deck = unicode() if profile is None else profile['deck']
|
deck = u'' if profile is None else profile['deck']
|
||||||
model = unicode() if profile is None else profile['model']
|
model = u'' if profile is None else profile['model']
|
||||||
|
|
||||||
self.comboBoxDeck.blockSignals(True)
|
self.comboBoxDeck.blockSignals(True)
|
||||||
self.comboBoxDeck.clear()
|
self.comboBoxDeck.clear()
|
||||||
@ -141,7 +141,7 @@ class DialogPreferences(QtGui.QDialog, gen.preferences_ui.Ui_DialogPreferences):
|
|||||||
itemName.setFlags(QtCore.Qt.ItemIsSelectable)
|
itemName.setFlags(QtCore.Qt.ItemIsSelectable)
|
||||||
columns.append(itemName)
|
columns.append(itemName)
|
||||||
|
|
||||||
itemValue = QtGui.QTableWidgetItem(fieldsPrefs.get(name, unicode()))
|
itemValue = QtGui.QTableWidgetItem(fieldsPrefs.get(name, u''))
|
||||||
columns.append(itemValue)
|
columns.append(itemValue)
|
||||||
|
|
||||||
for j, column in enumerate(columns):
|
for j, column in enumerate(columns):
|
||||||
|
@ -30,8 +30,8 @@ import updates
|
|||||||
class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
||||||
class State:
|
class State:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.filename = unicode()
|
self.filename = u''
|
||||||
self.searchText = unicode()
|
self.searchText = u''
|
||||||
self.kanjiDefs = []
|
self.kanjiDefs = []
|
||||||
self.vocabDefs = []
|
self.vocabDefs = []
|
||||||
self.scanPosition = 0
|
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.state.vocabDefs, length = self.language.findTerm(text, True)
|
||||||
self.updateVocabDefs()
|
self.updateVocabDefs()
|
||||||
if self.dockKanji.isVisible():
|
if self.dockKanji.isVisible():
|
||||||
self.state.kanjiDefs = self.language.findCharacters(text)
|
self.state.kanjiDefs = self.language.findKanji(text)
|
||||||
self.updateKanjiDefs()
|
self.updateKanjiDefs()
|
||||||
|
|
||||||
|
|
||||||
def onKanjiDefSearchReturn(self):
|
def onKanjiDefSearchReturn(self):
|
||||||
text = unicode(self.textKanjiSearch.text())
|
text = unicode(self.textKanjiSearch.text())
|
||||||
self.state.kanjiDefs = self.language.findCharacters(text)
|
self.state.kanjiDefs = self.language.findKanji(text)
|
||||||
self.updateKanjiDefs()
|
self.updateKanjiDefs()
|
||||||
|
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
self.preferences['textContent'] = unicode(self.textContent.toPlainText())
|
self.preferences['textContent'] = unicode(self.textContent.toPlainText())
|
||||||
|
|
||||||
self.setWindowTitle('Yomichan')
|
self.setWindowTitle('Yomichan')
|
||||||
self.textContent.setPlainText(unicode())
|
self.textContent.setPlainText(u'')
|
||||||
self.updateRecentFile(False)
|
self.updateRecentFile(False)
|
||||||
self.state = self.State()
|
self.state = self.State()
|
||||||
|
|
||||||
@ -493,7 +493,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
|
|
||||||
content = unicode(self.textContent.toPlainText())
|
content = unicode(self.textContent.toPlainText())
|
||||||
contentSample = content[samplePosStart:samplePosEnd]
|
contentSample = content[samplePosStart:samplePosEnd]
|
||||||
contentSampleFlat = contentSample.replace(u'\n', unicode())
|
contentSampleFlat = contentSample.replace(u'\n', u'')
|
||||||
|
|
||||||
cursor = self.textContent.textCursor()
|
cursor = self.textContent.textCursor()
|
||||||
|
|
||||||
@ -512,11 +512,11 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
|
|
||||||
if self.dockKanji.isVisible():
|
if self.dockKanji.isVisible():
|
||||||
if lengthMatched == 0:
|
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:
|
if len(self.state.kanjiDefs) > 0:
|
||||||
lengthMatched = 1
|
lengthMatched = 1
|
||||||
else:
|
else:
|
||||||
self.state.kanjiDefs = self.language.findCharacters(contentSampleFlat[:lengthMatched])
|
self.state.kanjiDefs = self.language.findKanji(contentSampleFlat[:lengthMatched])
|
||||||
self.updateKanjiDefs()
|
self.updateKanjiDefs()
|
||||||
|
|
||||||
lengthSelect = 0
|
lengthSelect = 0
|
||||||
@ -595,7 +595,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
self.state.vocabDefs += self.language.dictionary.findTerm(word)
|
self.state.vocabDefs += self.language.dictionary.findTerm(word)
|
||||||
|
|
||||||
if self.dockKanji.isVisible():
|
if self.dockKanji.isVisible():
|
||||||
self.state.kanjiDefs += self.language.findCharacters(word)
|
self.state.kanjiDefs += self.language.findKanji(word)
|
||||||
|
|
||||||
self.updateVocabDefs(scroll=True)
|
self.updateVocabDefs(scroll=True)
|
||||||
self.updateKanjiDefs(scroll=True)
|
self.updateKanjiDefs(scroll=True)
|
||||||
|
@ -37,7 +37,7 @@ def decodeContent(content):
|
|||||||
|
|
||||||
|
|
||||||
def stripReadings(content):
|
def stripReadings(content):
|
||||||
return re.sub(u'《[^》]+》', unicode(), content)
|
return re.sub(u'《[^》]+》', u'', content)
|
||||||
|
|
||||||
|
|
||||||
def findSentence(content, position):
|
def findSentence(content, position):
|
||||||
@ -105,7 +105,7 @@ def markupVocabExp(definition):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
'expression': definition['expression'],
|
'expression': definition['expression'],
|
||||||
'reading': definition['reading'] or unicode(),
|
'reading': definition['reading'] or u'',
|
||||||
'glossary': definition['glossary'],
|
'glossary': definition['glossary'],
|
||||||
'sentence': definition.get('sentence'),
|
'sentence': definition.get('sentence'),
|
||||||
'summary': summary
|
'summary': summary
|
||||||
@ -116,7 +116,7 @@ def markupVocabReading(definition):
|
|||||||
if definition['reading']:
|
if definition['reading']:
|
||||||
return {
|
return {
|
||||||
'expression': definition['reading'],
|
'expression': definition['reading'],
|
||||||
'reading': unicode(),
|
'reading': u'',
|
||||||
'glossary': definition['glossary'],
|
'glossary': definition['glossary'],
|
||||||
'sentence': definition.get('sentence'),
|
'sentence': definition.get('sentence'),
|
||||||
'summary': definition['reading']
|
'summary': definition['reading']
|
||||||
@ -170,11 +170,11 @@ def buildEmpty():
|
|||||||
|
|
||||||
|
|
||||||
def buildVocabDef(definition, index, query):
|
def buildVocabDef(definition, index, query):
|
||||||
reading = unicode()
|
reading = u''
|
||||||
if definition['reading']:
|
if definition['reading']:
|
||||||
reading = u'<span class="reading">[{0}]<br></span>'.format(definition['reading'])
|
reading = u'<span class="reading">[{0}]<br></span>'.format(definition['reading'])
|
||||||
|
|
||||||
rules = unicode()
|
rules = u''
|
||||||
if definition.get('rules'):
|
if definition.get('rules'):
|
||||||
rules = ' < '.join(definition['rules'])
|
rules = ' < '.join(definition['rules'])
|
||||||
rules = '<span class="rules">({0})<br></span>'.format(rules)
|
rules = '<span class="rules">({0})<br></span>'.format(rules)
|
||||||
|
Loading…
Reference in New Issue
Block a user