diff options
author | Jeroen Vermeulen <jtv@precisiontranslationtools.com> | 2015-05-17 16:04:04 +0300 |
---|---|---|
committer | Jeroen Vermeulen <jtv@precisiontranslationtools.com> | 2015-05-17 16:04:04 +0300 |
commit | a25193cc5da6a271c4676e843db80ee19221822a (patch) | |
tree | db764696f2e663016a9ab87a95846501c585b4aa /mingw | |
parent | 108da163745699e724f581c3d33b1e8a5e26a9e9 (diff) |
Fix a lot of lint, mostly trailing whitespace.
This is lint reported by the new lint-checking functionality in beautify.py.
(We can change to a different lint checker if we have a better one, but it
would probably still flag these same problems.)
Lint checking can help a lot, but only if we get the lint under control.
Diffstat (limited to 'mingw')
-rw-r--r-- | mingw/MosesGUI/Ui_addMTModel.py | 25 | ||||
-rw-r--r-- | mingw/MosesGUI/Ui_chooseMTModel.py | 26 | ||||
-rw-r--r-- | mingw/MosesGUI/Ui_credits.py | 25 | ||||
-rw-r--r-- | mingw/MosesGUI/Ui_mainWindow.py | 33 | ||||
-rw-r--r-- | mingw/MosesGUI/addMTModel.py | 21 | ||||
-rw-r--r-- | mingw/MosesGUI/chooseMTModel.py | 14 | ||||
-rw-r--r-- | mingw/MosesGUI/credits.py | 4 | ||||
-rw-r--r-- | mingw/MosesGUI/datamodel.py | 6 | ||||
-rw-r--r-- | mingw/MosesGUI/main.py | 3 |
9 files changed, 77 insertions, 80 deletions
diff --git a/mingw/MosesGUI/Ui_addMTModel.py b/mingw/MosesGUI/Ui_addMTModel.py index a312c6f23..a911be6d5 100644 --- a/mingw/MosesGUI/Ui_addMTModel.py +++ b/mingw/MosesGUI/Ui_addMTModel.py @@ -9,19 +9,17 @@ from PyQt4 import QtCore, QtGui -try: - _fromUtf8 = QtCore.QString.fromUtf8 -except AttributeError: - def _fromUtf8(s): - return s -try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) -except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) +_fromUtf8 = getattr(QtCore.QString, 'fromUtf8', lambda s: s) + + +def _translate(context, text, disambig): + return QtGui.QApplication.translate( + context, text, disambig, + getattr( + QtGui.QApplication, 'UnicodeUTF8', + QtCore.QCoreApplication.Encoding)) + class Ui_Dialog(object): def setupUi(self, Dialog): @@ -89,7 +87,7 @@ class Ui_Dialog(object): self.horizontalLayout_2.setStretch(1, 1) self.verticalLayout.addWidget(self.groupBox_2) self.buttonBox = QtGui.QDialogButtonBox(Dialog) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) self.verticalLayout.setStretch(1, 2) @@ -130,4 +128,3 @@ if __name__ == "__main__": ui.setupUi(Dialog) Dialog.show() sys.exit(app.exec_()) - diff --git a/mingw/MosesGUI/Ui_chooseMTModel.py b/mingw/MosesGUI/Ui_chooseMTModel.py index 993cd2598..246e88308 100644 --- a/mingw/MosesGUI/Ui_chooseMTModel.py +++ b/mingw/MosesGUI/Ui_chooseMTModel.py @@ -9,19 +9,17 @@ from PyQt4 import QtCore, QtGui -try: - _fromUtf8 = QtCore.QString.fromUtf8 -except AttributeError: - def _fromUtf8(s): - return s -try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) -except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) +_fromUtf8 = getattr(QtCore.QString, 'fromUtf8', lambda s: s) + + +def _translate(context, text, disambig): + return QtGui.QApplication.translate( + context, text, disambig, + getattr( + QtGui.QApplication, 'UnicodeUTF8', + QtCore.QCoreApplication.Encoding)) + class Ui_Dialog(object): def setupUi(self, Dialog): @@ -48,7 +46,8 @@ class Ui_Dialog(object): self.verticalLayout.addWidget(self.groupBox) self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setStandardButtons( + QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) @@ -70,4 +69,3 @@ if __name__ == "__main__": ui.setupUi(Dialog) Dialog.show() sys.exit(app.exec_()) - diff --git a/mingw/MosesGUI/Ui_credits.py b/mingw/MosesGUI/Ui_credits.py index c2e9c5d81..37759221c 100644 --- a/mingw/MosesGUI/Ui_credits.py +++ b/mingw/MosesGUI/Ui_credits.py @@ -9,19 +9,17 @@ from PyQt4 import QtCore, QtGui -try: - _fromUtf8 = QtCore.QString.fromUtf8 -except AttributeError: - def _fromUtf8(s): - return s -try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) -except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) +_fromUtf8 = getattr(QtCore.QString, 'fromUtf8', lambda s: s) + + +def _translate(context, text, disambig): + return QtGui.QApplication.translate( + context, text, disambig, + getattr( + QtGui.QApplication, 'UnicodeUTF8', + QtCore.QCoreApplication.Encoding)) + class Ui_Dialog(object): def setupUi(self, Dialog): @@ -29,7 +27,7 @@ class Ui_Dialog(object): Dialog.resize(359, 271) self.label = QtGui.QLabel(Dialog) self.label.setGeometry(QtCore.QRect(10, 10, 341, 211)) - self.label.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter) + self.label.setAlignment(QtCore.Qt.AlignJustify | QtCore.Qt.AlignVCenter) self.label.setWordWrap(True) self.label.setObjectName(_fromUtf8("label")) self.pushButton = QtGui.QPushButton(Dialog) @@ -62,4 +60,3 @@ if __name__ == "__main__": ui.setupUi(Dialog) Dialog.show() sys.exit(app.exec_()) - diff --git a/mingw/MosesGUI/Ui_mainWindow.py b/mingw/MosesGUI/Ui_mainWindow.py index b5d3fe006..3a7687fde 100644 --- a/mingw/MosesGUI/Ui_mainWindow.py +++ b/mingw/MosesGUI/Ui_mainWindow.py @@ -9,19 +9,17 @@ from PyQt4 import QtCore, QtGui -try: - _fromUtf8 = QtCore.QString.fromUtf8 -except AttributeError: - def _fromUtf8(s): - return s -try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) -except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) +_fromUtf8 = getattr(QtCore.QString, 'fromUtf8', lambda s: s) + + +def _translate(context, text, disambig): + return QtGui.QApplication.translate( + context, text, disambig, + getattr( + QtGui.QApplication, 'UnicodeUTF8', + QtCore.QCoreApplication.Encoding)) + class Ui_MainWindow(object): def setupUi(self, MainWindow): @@ -83,7 +81,10 @@ class Ui_MainWindow(object): self.editModelName.setObjectName(_fromUtf8("editModelName")) self.gridLayout.addWidget(self.editModelName, 1, 2, 1, 1) self.label_2 = QtGui.QLabel(self.groupBox) - self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_2.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) self.label_2.setObjectName(_fromUtf8("label_2")) self.gridLayout.addWidget(self.label_2, 1, 1, 1, 1) self.verticalLayout_2.addWidget(self.groupBox) @@ -151,7 +152,10 @@ class Ui_MainWindow(object): self.verticalLayout_3.addWidget(self.tabWidget) self.labelInfo = QtGui.QLabel(self.centralWidget) self.labelInfo.setTextFormat(QtCore.Qt.AutoText) - self.labelInfo.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelInfo.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) self.labelInfo.setObjectName(_fromUtf8("labelInfo")) self.verticalLayout_3.addWidget(self.labelInfo) MainWindow.setCentralWidget(self.centralWidget) @@ -185,4 +189,3 @@ if __name__ == "__main__": ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_()) - diff --git a/mingw/MosesGUI/addMTModel.py b/mingw/MosesGUI/addMTModel.py index 3fd4b14de..8d55400d5 100644 --- a/mingw/MosesGUI/addMTModel.py +++ b/mingw/MosesGUI/addMTModel.py @@ -7,16 +7,18 @@ Module implementing Dialog. from PyQt4.QtGui import * from PyQt4.QtCore import * -import os, datetime +import datetime +import os from Ui_addMTModel import Ui_Dialog from util import * + class AddMTModelDialog(QDialog, Ui_Dialog): """ Class documentation goes here. """ - def __init__(self, parent = None, workdir=None): + def __init__(self, parent=None, workdir=None): """ Constructor """ @@ -27,7 +29,7 @@ class AddMTModelDialog(QDialog, Ui_Dialog): todir, timestr = self.findEmptyDirWithTime(self.workdir) self.editPath.setText(todir) self.editName.setText("SampleModel_" + timestr) - + def findEmptyDirWithTime(self, workdir): if not self.timestr: self.timestr = datetime.datetime.now().strftime('%Y-%m-%d_%H%M%S') @@ -37,7 +39,7 @@ class AddMTModelDialog(QDialog, Ui_Dialog): break self.timestr = datetime.datetime.now().strftime('%Y-%m-%d_%H%M%S') return todir, self.timestr - + @pyqtSignature("") def on_btnLocal_clicked(self): """ @@ -49,7 +51,7 @@ class AddMTModelDialog(QDialog, Ui_Dialog): dialog.setViewMode(QFileDialog.Detail) if dialog.exec_(): self.editLocal.setText(dialog.selectedFiles()[0]) - + @pyqtSignature("") def on_btnPath_clicked(self): """ @@ -63,21 +65,21 @@ class AddMTModelDialog(QDialog, Ui_Dialog): root = str(dialog.selectedFiles()[0]) todir, _ = self.findEmptyDirWithTime(root) self.editPath.setText(todir) - + @pyqtSignature("bool") def on_grpBoxInternet_toggled(self, p0): """ Slot documentation goes here. """ self.grpBoxLocal.setChecked(not p0) - + @pyqtSignature("bool") def on_grpBoxLocal_toggled(self, p0): """ Slot documentation goes here. """ self.grpBoxInternet.setChecked(not p0) - + @pyqtSignature("") def on_buttonBox_accepted(self): """ @@ -85,7 +87,7 @@ class AddMTModelDialog(QDialog, Ui_Dialog): """ def checkEmpty(mystr): return len(str(mystr).strip()) <= 0 - + #check everything self.modelName = self.editName.text() if checkEmpty(self.modelName): @@ -111,4 +113,3 @@ class AddMTModelDialog(QDialog, Ui_Dialog): doAlert("Please provide non-empty Install Destination Folder") return self.accept() - diff --git a/mingw/MosesGUI/chooseMTModel.py b/mingw/MosesGUI/chooseMTModel.py index 52a6c8eed..95c566f1e 100644 --- a/mingw/MosesGUI/chooseMTModel.py +++ b/mingw/MosesGUI/chooseMTModel.py @@ -10,11 +10,12 @@ from PyQt4.QtSql import * from Ui_chooseMTModel import Ui_Dialog + class ChooseMTModelDialog(QDialog, Ui_Dialog): """ Class documentation goes here. """ - def __init__(self, parent = None, datamodel = None): + def __init__(self, parent=None, datamodel=None): """ Constructor """ @@ -29,16 +30,16 @@ class ChooseMTModelDialog(QDialog, Ui_Dialog): self.selTableView.hideColumn(6) #change status and keep the column QObject.connect(datamodel, SIGNAL("modelInstalled()"), self.on_datamodel_modelInstalled) - + def updateModel(self): self.model.setQuery('SELECT ID, name, srclang, trglang, status, path, mosesini FROM models WHERE status = "READY" AND deleted != "True"', self.database) - + def on_datamodel_recordUpdated(self, bRecord): #deal with the selection changed problem try: if bRecord: current = self.selTableView.currentIndex() - if current and current.row() <> -1: + if current and current.row() != -1: self.curSelection = current.row() else: self.curSelection = None @@ -47,10 +48,10 @@ class ChooseMTModelDialog(QDialog, Ui_Dialog): self.selTableView.selectRow(self.curSelection) except Exception, e: print >> sys.stderr, str(e) - + def on_datamodel_modelInstalled(self): self.updateModel() - + @pyqtSignature("") def on_buttonBox_accepted(self): """ @@ -68,4 +69,3 @@ class ChooseMTModelDialog(QDialog, Ui_Dialog): self.path = record.value("path").toString() self.mosesini = record.value("mosesini").toString() self.accept() - diff --git a/mingw/MosesGUI/credits.py b/mingw/MosesGUI/credits.py index 6b1b97a05..43aa4f381 100644 --- a/mingw/MosesGUI/credits.py +++ b/mingw/MosesGUI/credits.py @@ -9,18 +9,18 @@ from PyQt4.QtCore import pyqtSignature, QUrl from Ui_credits import Ui_Dialog + class DlgCredits(QDialog, Ui_Dialog): """ Class documentation goes here. """ - def __init__(self, parent = None): + def __init__(self, parent=None): """ Constructor """ QDialog.__init__(self, parent) self.setupUi(self) - @pyqtSignature("QString") def on_label_linkActivated(self, link): """ diff --git a/mingw/MosesGUI/datamodel.py b/mingw/MosesGUI/datamodel.py index ad802e439..16076043f 100644 --- a/mingw/MosesGUI/datamodel.py +++ b/mingw/MosesGUI/datamodel.py @@ -248,7 +248,7 @@ Click "Cancel" to do nothing.''' msg = 'COPY %.0f%%' % ( download_size * 100.0 / total_size) else: - msg = 'COPY %d MB' % (download_size/1048576) + msg = 'COPY %d MB' % (download_size / 1048576) if msg != lastMsg: updateRecord({'status': msg}) lastMsg = msg @@ -289,7 +289,7 @@ Click "Cancel" to do nothing.''' msg = 'DOWNLOAD %.0f%%' % ( download_size * 100.0 / total_size) else: - msg = 'DOWNLOAD %d MB' % (download_size/1048576) + msg = 'DOWNLOAD %d MB' % (download_size / 1048576) if msg != lastMsg: updateRecord({'status': msg}) lastMsg = msg @@ -359,7 +359,7 @@ Click "Cancel" to do nothing.''' download_size * 100.0 / total_size) else: msg = 'UNZIP %d MB' % ( - download_size/1048576) + download_size / 1048576) if msg != lastMsg: updateRecord({'status': msg}) lastMsg = msg diff --git a/mingw/MosesGUI/main.py b/mingw/MosesGUI/main.py index e2a08d03a..805a7bc0c 100644 --- a/mingw/MosesGUI/main.py +++ b/mingw/MosesGUI/main.py @@ -3,7 +3,8 @@ from PyQt4.QtCore import * from PyQt4.QtGui import * -import sys, os +import os +import sys from mainWindow import MainWindow from datamodel import DataModel |