Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Vermeulen <jtv@precisiontranslationtools.com>2015-06-02 12:02:39 +0300
committerJeroen Vermeulen <jtv@precisiontranslationtools.com>2015-06-02 12:02:39 +0300
commit0981d2370505672d027d0f6e17890fb36286c439 (patch)
treef379a501e9100efe30114141f09144131a0cf6ff /mingw/MosesGUI
parent35cf55d4d25eaff8c99a6467e7fc923f35ac7aa7 (diff)
Lint-fixing binge.
Diffstat (limited to 'mingw/MosesGUI')
-rw-r--r--mingw/MosesGUI/addMTModel.py11
-rw-r--r--mingw/MosesGUI/chooseMTModel.py31
-rw-r--r--mingw/MosesGUI/main.py4
-rw-r--r--mingw/MosesGUI/mainWindow.py71
4 files changed, 79 insertions, 38 deletions
diff --git a/mingw/MosesGUI/addMTModel.py b/mingw/MosesGUI/addMTModel.py
index 8d55400d5..09e6fc542 100644
--- a/mingw/MosesGUI/addMTModel.py
+++ b/mingw/MosesGUI/addMTModel.py
@@ -4,14 +4,17 @@
Module implementing Dialog.
"""
-from PyQt4.QtGui import *
-from PyQt4.QtCore import *
+from PyQt4.QtGui import (
+ QDialog,
+ QFileDialog,
+ )
+from PyQt4.QtCore import pyqtSignature
import datetime
import os
from Ui_addMTModel import Ui_Dialog
-from util import *
+from util import doAlert
class AddMTModelDialog(QDialog, Ui_Dialog):
@@ -88,7 +91,7 @@ class AddMTModelDialog(QDialog, Ui_Dialog):
def checkEmpty(mystr):
return len(str(mystr).strip()) <= 0
- #check everything
+ # Check everything.
self.modelName = self.editName.text()
if checkEmpty(self.modelName):
doAlert("Please provide non-empty Model Name")
diff --git a/mingw/MosesGUI/chooseMTModel.py b/mingw/MosesGUI/chooseMTModel.py
index 95c566f1e..5702216b8 100644
--- a/mingw/MosesGUI/chooseMTModel.py
+++ b/mingw/MosesGUI/chooseMTModel.py
@@ -4,11 +4,18 @@
Module implementing ChooseMTModelDialog.
"""
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-from PyQt4.QtSql import *
+import sys
+
+from PyQt4.QtCore import (
+ pyqtSignature,
+ QObject,
+ SIGNAL,
+ )
+from PyQt4.QtGui import QDialog
+from PyQt4.QtSql import QSqlQueryModel
from Ui_chooseMTModel import Ui_Dialog
+from util import doAlert
class ChooseMTModelDialog(QDialog, Ui_Dialog):
@@ -28,14 +35,20 @@ class ChooseMTModelDialog(QDialog, Ui_Dialog):
self.selTableView.hideColumn(0)
self.selTableView.hideColumn(5)
self.selTableView.hideColumn(6)
- #change status and keep the column
- QObject.connect(datamodel, SIGNAL("modelInstalled()"), self.on_datamodel_modelInstalled)
+ # 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)
+ 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
+ """Deal with the selection changed problem."""
try:
if bRecord:
current = self.selTableView.currentIndex()
@@ -44,9 +57,9 @@ class ChooseMTModelDialog(QDialog, Ui_Dialog):
else:
self.curSelection = None
else:
- if not self.curSelection is None:
+ if self.curSelection is not None:
self.selTableView.selectRow(self.curSelection)
- except Exception, e:
+ except Exception as e:
print >> sys.stderr, str(e)
def on_datamodel_modelInstalled(self):
diff --git a/mingw/MosesGUI/main.py b/mingw/MosesGUI/main.py
index 805a7bc0c..3bab0e617 100644
--- a/mingw/MosesGUI/main.py
+++ b/mingw/MosesGUI/main.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
+from PyQt4.QtGui import QApplication
import os
import sys
@@ -9,7 +8,6 @@ import sys
from mainWindow import MainWindow
from datamodel import DataModel
from moses import Moses
-from util import *
if __name__ == "__main__":
app = QApplication(sys.argv)
diff --git a/mingw/MosesGUI/mainWindow.py b/mingw/MosesGUI/mainWindow.py
index 5fb031c50..e92cdbb92 100644
--- a/mingw/MosesGUI/mainWindow.py
+++ b/mingw/MosesGUI/mainWindow.py
@@ -4,10 +4,19 @@
Module implementing MainWindow.
"""
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-from PyQt4.QtSql import *
+from PyQt4.QtCore import (
+ pyqtSignature,
+ QObject,
+ Qt,
+ SIGNAL,
+ )
+from PyQt4.QtGui import (
+ QMainWindow,
+ QMessageBox,
+ QProgressDialog,
+ )
+import sys
import threading
from Ui_mainWindow import Ui_MainWindow
@@ -15,7 +24,7 @@ from addMTModel import AddMTModelDialog
from chooseMTModel import ChooseMTModelDialog
from engine import Engine
from credits import DlgCredits
-from util import *
+from util import doAlert
class MainWindow(QMainWindow, Ui_MainWindow):
@@ -54,18 +63,27 @@ class MainWindow(QMainWindow, Ui_MainWindow):
Slot documentation goes here.
"""
current = self.tableView.currentIndex()
- if current and current.row() >= 0:
- if self.engine and self.datamodel.getRowID(current.row()) == self.engine.model['ID']:
- text = '''The model is still in use, do you want to stop and delete it?
-It might take a while...'''
- reply = QMessageBox.question(None, 'Message', text, QMessageBox.Yes, QMessageBox.No)
- if reply == QMessageBox.No:
- return
- t = self.stopEngine(self.engine)
- t.join()
- self.engine = None
- self.clearPanel()
- self.datamodel.delModel(current.row())
+ if not current or current.row() < 0:
+ return
+ model_in_use = (
+ self.engine and
+ self.datamodel.getRowID(current.row()) == self.engine.model['ID']
+ )
+ if model_in_use:
+ text = (
+ "The model is still in use, do you want to "
+ "stop and delete it?\n"
+ "It might take a while..."
+ )
+ reply = QMessageBox.question(
+ None, 'Message', text, QMessageBox.Yes, QMessageBox.No)
+ if reply == QMessageBox.No:
+ return
+ t = self.stopEngine(self.engine)
+ t.join()
+ self.engine = None
+ self.clearPanel()
+ self.datamodel.delModel(current.row())
@pyqtSignature("")
def on_newModelBtn_clicked(self):
@@ -153,17 +171,24 @@ It might take a while...'''
if self.progress:
self.progress.close()
self.progress = None
- self.progress = QProgressDialog("Model: %s" % model['name'], "Cancel", 0, self.engine.countSteps(), self)
+ self.progress = QProgressDialog(
+ "Model: %s" % model['name'], "Cancel", 0,
+ self.engine.countSteps(), self)
self.progress.setAutoReset(True)
self.progress.setAutoClose(True)
self.progress.setWindowModality(Qt.WindowModal)
self.progress.setWindowTitle('Loading Model...')
- QObject.connect(self.progress, SIGNAL("canceled()"), self.progressCancelled)
+ QObject.connect(
+ self.progress, SIGNAL("canceled()"), self.progressCancelled)
self.progress.show()
- #connect engine signal
- QObject.connect(self.engine, SIGNAL("stepFinished(int)"), self.engineStepFinished)
- QObject.connect(self.engine, SIGNAL("loaded(bool, QString)"), self.engineLoaded)
+ # Connect engine signal.
+ QObject.connect(
+ self.engine, SIGNAL("stepFinished(int)"),
+ self.engineStepFinished)
+ QObject.connect(
+ self.engine, SIGNAL("loaded(bool, QString)"),
+ self.engineLoaded)
def startEngineThread():
self.engine.start()
@@ -225,7 +250,9 @@ It might take a while...'''
if text.strip() == "":
trans.append(text)
else:
- trans.append(self.engine.translate(text.replace('\r', ' ').strip()).decode('utf8'))
+ trans.append(
+ self.engine.translate(
+ text.replace('\r', ' ').strip()).decode('utf8'))
self.editTrg.setText('\n'.join(trans))
except Exception, e:
print >> sys.stderr, str(e)