ProjectPyramid/Project.py

changeset 140
a891fb543d28
parent 138
72ebb74aa42d
child 142
77e872c9c300
--- a/ProjectPyramid/Project.py	Tue Jun 23 18:14:33 2020 +0200
+++ b/ProjectPyramid/Project.py	Wed Oct 14 19:00:12 2020 +0200
@@ -505,7 +505,7 @@
         from .FormSelectionDialog import FormSelectionDialog
         
         dlg = FormSelectionDialog()
-        if dlg.exec_() == QDialog.Accepted:
+        if dlg.exec() == QDialog.Accepted:
             template = dlg.getTemplateText()
             
             fileFilters = self.tr(
@@ -542,9 +542,8 @@
                         return
                 
                 try:
-                    f = open(fname, "w", encoding="utf-8")
-                    f.write(template)
-                    f.close()
+                    with open(fname, "w", encoding="utf-8") as f:
+                        f.write(template)
                 except IOError as e:
                     E5MessageBox.critical(
                         self.__ui,
@@ -632,9 +631,8 @@
                             fullCmds = self.__getExecutablePaths(cmd)
                         for fullCmd in fullCmds:
                             try:
-                                f = open(fullCmd, 'r', encoding='utf-8')
-                                l0 = f.readline()
-                                f.close()
+                                with open(fullCmd, 'r', encoding='utf-8') as f:
+                                    l0 = f.readline()
                             except (IOError, OSError):
                                 l0 = ""
                             if self.__isSuitableForVariant(variant, l0):
@@ -802,7 +800,7 @@
             os.path.join("ProjectPyramid", "icons",
                          "pyramid64-{0}".format(self.__iconSuffix))
         ))
-        msgBox.exec_()
+        msgBox.exec()
     
     def getPyramidVersionString(self):
         """
@@ -816,9 +814,8 @@
             if isWindowsPlatform():
                 cmd = os.path.join(os.path.dirname(cmd), "pcreate-script.py")
             try:
-                f = open(cmd, 'r', encoding="utf-8")
-                lines = f.read().splitlines()
-                f.close()
+                with open(cmd, 'r', encoding="utf-8") as f:
+                    lines = f.read().splitlines()
                 for line in lines:
                     if line.startswith("__requires__"):
                         ## sample: __requires__ = 'pyramid==1.4'
@@ -890,7 +887,7 @@
         from .CreateParametersDialog import CreateParametersDialog
         
         dlg = CreateParametersDialog(self)
-        if dlg.exec_() == QDialog.Accepted:
+        if dlg.exec() == QDialog.Accepted:
             scaffold, project, overwrite, simulate = dlg.getData()
             
             cmd = self.getPyramidCommand("pcreate")
@@ -906,7 +903,7 @@
             dlg = PyramidDialog(self.tr("Create Pyramid Project"),
                                 linewrap=False, parent=self.__ui)
             if dlg.startProcess(cmd, args, self.__e5project.getProjectPath()):
-                dlg.exec_()
+                dlg.exec()
                 if dlg.normalExit() and not simulate:
                     # search for files created by pcreate and add them to the
                     # project
@@ -1226,7 +1223,7 @@
                                " successfully."))
         res = dia.startProcess(cmd, args, wd)
         if res:
-            dia.exec_()
+            dia.exec()
             initCmd = self.__getInitDbCommand()
             self.initializeDbAct.setEnabled(os.path.exists(initCmd))
     
@@ -1255,7 +1252,7 @@
         )
         
         dlg = DistributionTypeSelectionDialog(self, projectPath, self.__ui)
-        if dlg.exec_() == QDialog.Accepted:
+        if dlg.exec() == QDialog.Accepted:
             formats = dlg.getFormats()
             cmd = self.getPythonCommand()
             args = []
@@ -1270,7 +1267,7 @@
                                    " successfully."))
             res = dia.startProcess(cmd, args, projectPath)
             if res:
-                dia.exec_()
+                dia.exec()
     
     ##################################################################
     ## slots below implement database functions
@@ -1317,7 +1314,7 @@
             msgSuccess=self.tr("Database initialized successfully."))
         res = dia.startProcess(cmd, args, projectPath)
         if res:
-            dia.exec_()
+            dia.exec()
     
     ##################################################################
     ## slots below implement various debugging functions
@@ -1355,7 +1352,7 @@
         dia = PyramidDialog(title, fixed=True, linewrap=False)
         res = dia.startProcess(cmd, args, projectPath)
         if res:
-            dia.exec_()
+            dia.exec()
     
     def __showRoutes(self):
         """
@@ -1377,7 +1374,7 @@
         dia = PyramidRoutesDialog(self)
         res = dia.start(projectPath)
         if res:
-            dia.exec_()
+            dia.exec()
     
     def __showTweens(self):
         """
@@ -1401,7 +1398,7 @@
         dia = PyramidDialog(title, fixed=True, linewrap=False)
         res = dia.startProcess(cmd, args, projectPath)
         if res:
-            dia.exec_()
+            dia.exec()
     
     ##################################################################
     ## slots below implement documentation functions
@@ -1519,7 +1516,7 @@
             msgSuccess=self.tr("\nMessages extracted successfully."))
         res = dia.startProcess(cmd, args, projectPath)
         if res:
-            dia.exec_()
+            dia.exec()
             self.__e5project.appendFile(os.path.join(projectPath, potFile))
             
     def __projectLanguageAdded(self, code):
@@ -1553,7 +1550,7 @@
                                " successfully."))
         res = dia.startProcess(cmd, args, projectPath)
         if res:
-            dia.exec_()
+            dia.exec()
             
             langFile = self.__e5project.getTranslationPattern().replace(
                 "%language%", code)
@@ -1587,7 +1584,7 @@
                                " successfully."))
         res = dia.startProcess(cmd, args, projectPath)
         if res:
-            dia.exec_()
+            dia.exec()
         
             for entry in os.walk(projectPath):
                 for fileName in entry[2]:
@@ -1639,7 +1636,7 @@
                                " successfully."))
         res = dia.startBatchProcesses(argsLists, projectPath)
         if res:
-            dia.exec_()
+            dia.exec()
             
             for entry in os.walk(self.__sitePath()):
                 for fileName in entry[2]:
@@ -1674,7 +1671,7 @@
             msgSuccess=self.tr("\nMessage catalogs updated successfully."))
         res = dia.startProcess(cmd, args, projectPath)
         if res:
-            dia.exec_()
+            dia.exec()
     
     def updateSelectedCatalogs(self, filenames):
         """
@@ -1719,7 +1716,7 @@
             msgSuccess=self.tr("\nMessage catalogs updated successfully."))
         res = dia.startBatchProcesses(argsLists, projectPath)
         if res:
-            dia.exec_()
+            dia.exec()
     
     def openPOEditor(self, poFile):
         """

eric ide

mercurial