From c8d6ec9cd7262cbc6c00bc269f3d4b7b99d0caac Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 9 Nov 2013 18:49:31 -0800 Subject: [PATCH] Small fixups and tweaks Former-commit-id: 8de377f8989f696a3a0db9ddb5830ab414634c24 --- util/compile.py | 3 ++- yomi_base/about.py | 6 +++--- yomi_base/anki_bridge.py | 4 ++-- yomi_base/constants.py | 11 +++++------ yomi_base/preference_data.py | 6 +++--- yomi_base/preferences.py | 2 +- yomi_base/reader.py | 22 +++++++++++----------- yomi_base/update.py | 12 ++++++------ yomichan.py | 4 ++-- 9 files changed, 35 insertions(+), 35 deletions(-) diff --git a/util/compile.py b/util/compile.py index 1a80ada..7a7cfef 100755 --- a/util/compile.py +++ b/util/compile.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -# 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 @@ -17,6 +17,7 @@ # along with this program. If not, see . # + import codecs import optparse import os diff --git a/yomi_base/about.py b/yomi_base/about.py index f7cedae..2f51a19 100644 --- a/yomi_base/about.py +++ b/yomi_base/about.py @@ -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 @@ -17,8 +17,8 @@ from PyQt4 import QtGui -from constants import constants from gen import about_ui +import constants class DialogAbout(QtGui.QDialog, about_ui.Ui_DialogAbout): @@ -27,5 +27,5 @@ class DialogAbout(QtGui.QDialog, about_ui.Ui_DialogAbout): self.setupUi(self) text = unicode(self.labelVersion.text()) - text = text.format(constants['version']) + text = text.format(constants.c['appVersion']) self.labelVersion.setText(text) diff --git a/yomi_base/anki_bridge.py b/yomi_base/anki_bridge.py index 7a08aee..edc57ef 100644 --- a/yomi_base/anki_bridge.py +++ b/yomi_base/anki_bridge.py @@ -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 @@ -16,8 +16,8 @@ # along with this program. If not, see . -import aqt import anki +import aqt class Anki: diff --git a/yomi_base/constants.py b/yomi_base/constants.py index 426ce49..3ba51f6 100644 --- a/yomi_base/constants.py +++ b/yomi_base/constants.py @@ -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 @@ -16,10 +16,9 @@ # along with this program. If not, see . -constants = { - 'version': '0.07b', - - 'urlUpdates': 'http://foosoft.net/pub/projects/yomichan/updates.xml', +c = { + 'appVersion': '0.10b', + 'urlFeedback': 'http://foosoft.net/comments/', 'urlHomepage': 'http://foosoft.net/yomichan/', - 'urlFeedback': 'http://foosoft.net/comments/' + 'urlUpdates': 'http://foosoft.net/pub/projects/yomichan/updates.xml', } diff --git a/yomi_base/preference_data.py b/yomi_base/preference_data.py index cd1b099..2626e7a 100644 --- a/yomi_base/preference_data.py +++ b/yomi_base/preference_data.py @@ -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 @@ -16,9 +16,9 @@ # along with this program. If not, see . -import os -from xml.dom import minidom from PyQt4 import QtCore, QtGui +from xml.dom import minidom +import os class Preferences: diff --git a/yomi_base/preferences.py b/yomi_base/preferences.py index f580d1f..e1171de 100644 --- a/yomi_base/preferences.py +++ b/yomi_base/preferences.py @@ -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 diff --git a/yomi_base/reader.py b/yomi_base/reader.py index 92e93a3..879b35b 100644 --- a/yomi_base/reader.py +++ b/yomi_base/reader.py @@ -16,15 +16,15 @@ # along with this program. If not, see . -import os -import tarfile from PyQt4 import QtGui, QtCore -from preferences import DialogPreferences -from update import UpdateFinder from about import DialogAbout -from constants import constants from gen import reader_ui +from preferences import DialogPreferences +import constants +import os import reader_util +import tarfile +import update class MainWindowReader(QtGui.QMainWindow, reader_ui.Ui_MainWindowReader): @@ -47,7 +47,7 @@ class MainWindowReader(QtGui.QMainWindow, reader_ui.Ui_MainWindowReader): self.dockAnki.setEnabled(bool(anki)) self.preferences = preferences - self.updateFinder = UpdateFinder() + self.updateFinder = update.UpdateFinder() self.state = self.State() self.language = language self.addedFacts = list() @@ -235,12 +235,12 @@ class MainWindowReader(QtGui.QMainWindow, reader_ui.Ui_MainWindowReader): def onActionHomepage(self): - url = QtCore.QUrl(constants['urlHomepage']) + url = QtCore.QUrl(constants.c['urlHomepage']) QtGui.QDesktopServices().openUrl(url) def onActionFeedback(self): - url = QtCore.QUrl(constants['urlFeedback']) + url = QtCore.QUrl(constants.c['urlFeedback']) QtGui.QDesktopServices().openUrl(url) @@ -285,12 +285,12 @@ class MainWindowReader(QtGui.QMainWindow, reader_ui.Ui_MainWindowReader): def onUpdaterSearchResult(self, result): - if result and unicode(result) > constants['version']: + if result and unicode(result) > constants.c['appVersion']: QtGui.QMessageBox.information( self, 'Yomichan', 'A new version of Yomichan is available for download!\n\nYou can download this update ({0} > {1}) ' \ - 'from "Shared Plugins" in Anki or directly from the Yomichan homepage.'.format(constants['version'], result) + 'from "Shared Plugins" in Anki or directly from the Yomichan homepage.'.format(constants.c['appVersion'], result) ) @@ -447,7 +447,7 @@ class MainWindowReader(QtGui.QMainWindow, reader_ui.Ui_MainWindowReader): if markup['reading']: summary = u'{expression} [{reading}]'.format(**markup) else: - summary = expression + summary = markup['expression'] self.addedFacts.append(factId) self.listDefinitions.addItem(summary) diff --git a/yomi_base/update.py b/yomi_base/update.py index e4315dc..ba3e152 100644 --- a/yomi_base/update.py +++ b/yomi_base/update.py @@ -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 @@ -16,10 +16,10 @@ # along with this program. If not, see . -import urllib2 -from xml.dom import minidom from PyQt4 import QtCore -from constants import constants +from xml.dom import minidom +import constants +import urllib2 class UpdateFinder(QtCore.QThread): @@ -28,7 +28,7 @@ class UpdateFinder(QtCore.QThread): def run(self): latest = None try: - fp = urllib2.urlopen(constants['urlUpdates']) + fp = urllib2.urlopen(constants.c['urlUpdates']) data = fp.read() doc = minidom.parseString(data) root = doc.documentElement @@ -37,4 +37,4 @@ class UpdateFinder(QtCore.QThread): except: pass finally: - self.updateResult.emit(latest or constants['version']) + self.updateResult.emit(latest or constants.c['appVersion']) diff --git a/yomichan.py b/yomichan.py index 2473276..7c3ebe9 100755 --- a/yomichan.py +++ b/yomichan.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # -*- 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 @@ -17,11 +17,11 @@ # along with this program. If not, see . -import sys from PyQt4 import QtGui, QtCore from yomi_base import japanese from yomi_base.preference_data import Preferences from yomi_base.reader import MainWindowReader +import sys class Yomichan: