503 @param path full directory path for the new form file (string) |
503 @param path full directory path for the new form file (string) |
504 """ |
504 """ |
505 from .FormSelectionDialog import FormSelectionDialog |
505 from .FormSelectionDialog import FormSelectionDialog |
506 |
506 |
507 dlg = FormSelectionDialog() |
507 dlg = FormSelectionDialog() |
508 if dlg.exec_() == QDialog.Accepted: |
508 if dlg.exec() == QDialog.Accepted: |
509 template = dlg.getTemplateText() |
509 template = dlg.getTemplateText() |
510 |
510 |
511 fileFilters = self.tr( |
511 fileFilters = self.tr( |
512 "Chameleon Templates (*.pt);;" |
512 "Chameleon Templates (*.pt);;" |
513 "Chameleon Text Templates (*.txt);;" |
513 "Chameleon Text Templates (*.txt);;" |
540 if not res: |
540 if not res: |
541 # user selected to not overwrite |
541 # user selected to not overwrite |
542 return |
542 return |
543 |
543 |
544 try: |
544 try: |
545 f = open(fname, "w", encoding="utf-8") |
545 with open(fname, "w", encoding="utf-8") as f: |
546 f.write(template) |
546 f.write(template) |
547 f.close() |
|
548 except IOError as e: |
547 except IOError as e: |
549 E5MessageBox.critical( |
548 E5MessageBox.critical( |
550 self.__ui, |
549 self.__ui, |
551 self.tr("New Form"), |
550 self.tr("New Form"), |
552 self.tr("<p>The new form file <b>{0}</b> could" |
551 self.tr("<p>The new form file <b>{0}</b> could" |
630 fullCmds = Utilities.getExecutablePaths(cmd) |
629 fullCmds = Utilities.getExecutablePaths(cmd) |
631 except AttributeError: |
630 except AttributeError: |
632 fullCmds = self.__getExecutablePaths(cmd) |
631 fullCmds = self.__getExecutablePaths(cmd) |
633 for fullCmd in fullCmds: |
632 for fullCmd in fullCmds: |
634 try: |
633 try: |
635 f = open(fullCmd, 'r', encoding='utf-8') |
634 with open(fullCmd, 'r', encoding='utf-8') as f: |
636 l0 = f.readline() |
635 l0 = f.readline() |
637 f.close() |
|
638 except (IOError, OSError): |
636 except (IOError, OSError): |
639 l0 = "" |
637 l0 = "" |
640 if self.__isSuitableForVariant(variant, l0): |
638 if self.__isSuitableForVariant(variant, l0): |
641 variants.append(variant) |
639 variants.append(variant) |
642 break |
640 break |
800 buttons=E5MessageBox.Ok) |
798 buttons=E5MessageBox.Ok) |
801 msgBox.setIconPixmap(UI.PixmapCache.getPixmap( |
799 msgBox.setIconPixmap(UI.PixmapCache.getPixmap( |
802 os.path.join("ProjectPyramid", "icons", |
800 os.path.join("ProjectPyramid", "icons", |
803 "pyramid64-{0}".format(self.__iconSuffix)) |
801 "pyramid64-{0}".format(self.__iconSuffix)) |
804 )) |
802 )) |
805 msgBox.exec_() |
803 msgBox.exec() |
806 |
804 |
807 def getPyramidVersionString(self): |
805 def getPyramidVersionString(self): |
808 """ |
806 """ |
809 Public method to get the Pyramid version as a string. |
807 Public method to get the Pyramid version as a string. |
810 |
808 |
814 if not self.__pyramidVersion: |
812 if not self.__pyramidVersion: |
815 cmd = self.getPyramidCommand("pcreate") |
813 cmd = self.getPyramidCommand("pcreate") |
816 if isWindowsPlatform(): |
814 if isWindowsPlatform(): |
817 cmd = os.path.join(os.path.dirname(cmd), "pcreate-script.py") |
815 cmd = os.path.join(os.path.dirname(cmd), "pcreate-script.py") |
818 try: |
816 try: |
819 f = open(cmd, 'r', encoding="utf-8") |
817 with open(cmd, 'r', encoding="utf-8") as f: |
820 lines = f.read().splitlines() |
818 lines = f.read().splitlines() |
821 f.close() |
|
822 for line in lines: |
819 for line in lines: |
823 if line.startswith("__requires__"): |
820 if line.startswith("__requires__"): |
824 ## sample: __requires__ = 'pyramid==1.4' |
821 ## sample: __requires__ = 'pyramid==1.4' |
825 vers = line.strip().split()[-1][1:-1].split("==")[1] |
822 vers = line.strip().split()[-1][1:-1].split("==")[1] |
826 self.__pyramidVersion = vers |
823 self.__pyramidVersion = vers |
888 Private slot to create a new Pyramid project. |
885 Private slot to create a new Pyramid project. |
889 """ |
886 """ |
890 from .CreateParametersDialog import CreateParametersDialog |
887 from .CreateParametersDialog import CreateParametersDialog |
891 |
888 |
892 dlg = CreateParametersDialog(self) |
889 dlg = CreateParametersDialog(self) |
893 if dlg.exec_() == QDialog.Accepted: |
890 if dlg.exec() == QDialog.Accepted: |
894 scaffold, project, overwrite, simulate = dlg.getData() |
891 scaffold, project, overwrite, simulate = dlg.getData() |
895 |
892 |
896 cmd = self.getPyramidCommand("pcreate") |
893 cmd = self.getPyramidCommand("pcreate") |
897 args = [] |
894 args = [] |
898 if overwrite: |
895 if overwrite: |
904 args.append("--scaffold={0}".format(scaffold)) |
901 args.append("--scaffold={0}".format(scaffold)) |
905 args.append(project) |
902 args.append(project) |
906 dlg = PyramidDialog(self.tr("Create Pyramid Project"), |
903 dlg = PyramidDialog(self.tr("Create Pyramid Project"), |
907 linewrap=False, parent=self.__ui) |
904 linewrap=False, parent=self.__ui) |
908 if dlg.startProcess(cmd, args, self.__e5project.getProjectPath()): |
905 if dlg.startProcess(cmd, args, self.__e5project.getProjectPath()): |
909 dlg.exec_() |
906 dlg.exec() |
910 if dlg.normalExit() and not simulate: |
907 if dlg.normalExit() and not simulate: |
911 # search for files created by pcreate and add them to the |
908 # search for files created by pcreate and add them to the |
912 # project |
909 # project |
913 projectPath = os.path.join( |
910 projectPath = os.path.join( |
914 self.__e5project.getProjectPath(), project) |
911 self.__e5project.getProjectPath(), project) |
1224 title, |
1221 title, |
1225 msgSuccess=self.tr("Pyramid development environment setup" |
1222 msgSuccess=self.tr("Pyramid development environment setup" |
1226 " successfully.")) |
1223 " successfully.")) |
1227 res = dia.startProcess(cmd, args, wd) |
1224 res = dia.startProcess(cmd, args, wd) |
1228 if res: |
1225 if res: |
1229 dia.exec_() |
1226 dia.exec() |
1230 initCmd = self.__getInitDbCommand() |
1227 initCmd = self.__getInitDbCommand() |
1231 self.initializeDbAct.setEnabled(os.path.exists(initCmd)) |
1228 self.initializeDbAct.setEnabled(os.path.exists(initCmd)) |
1232 |
1229 |
1233 ################################################################## |
1230 ################################################################## |
1234 ## slots below implement distribution functions |
1231 ## slots below implement distribution functions |
1253 from .DistributionTypeSelectionDialog import ( |
1250 from .DistributionTypeSelectionDialog import ( |
1254 DistributionTypeSelectionDialog |
1251 DistributionTypeSelectionDialog |
1255 ) |
1252 ) |
1256 |
1253 |
1257 dlg = DistributionTypeSelectionDialog(self, projectPath, self.__ui) |
1254 dlg = DistributionTypeSelectionDialog(self, projectPath, self.__ui) |
1258 if dlg.exec_() == QDialog.Accepted: |
1255 if dlg.exec() == QDialog.Accepted: |
1259 formats = dlg.getFormats() |
1256 formats = dlg.getFormats() |
1260 cmd = self.getPythonCommand() |
1257 cmd = self.getPythonCommand() |
1261 args = [] |
1258 args = [] |
1262 args.append("setup.py") |
1259 args.append("setup.py") |
1263 args.append("sdist") |
1260 args.append("sdist") |
1268 title, |
1265 title, |
1269 msgSuccess=self.tr("Python distribution file built" |
1266 msgSuccess=self.tr("Python distribution file built" |
1270 " successfully.")) |
1267 " successfully.")) |
1271 res = dia.startProcess(cmd, args, projectPath) |
1268 res = dia.startProcess(cmd, args, projectPath) |
1272 if res: |
1269 if res: |
1273 dia.exec_() |
1270 dia.exec() |
1274 |
1271 |
1275 ################################################################## |
1272 ################################################################## |
1276 ## slots below implement database functions |
1273 ## slots below implement database functions |
1277 ################################################################## |
1274 ################################################################## |
1278 |
1275 |
1315 dia = PyramidDialog( |
1312 dia = PyramidDialog( |
1316 title, |
1313 title, |
1317 msgSuccess=self.tr("Database initialized successfully.")) |
1314 msgSuccess=self.tr("Database initialized successfully.")) |
1318 res = dia.startProcess(cmd, args, projectPath) |
1315 res = dia.startProcess(cmd, args, projectPath) |
1319 if res: |
1316 if res: |
1320 dia.exec_() |
1317 dia.exec() |
1321 |
1318 |
1322 ################################################################## |
1319 ################################################################## |
1323 ## slots below implement various debugging functions |
1320 ## slots below implement various debugging functions |
1324 ################################################################## |
1321 ################################################################## |
1325 |
1322 |
1353 args.append(url) |
1350 args.append(url) |
1354 |
1351 |
1355 dia = PyramidDialog(title, fixed=True, linewrap=False) |
1352 dia = PyramidDialog(title, fixed=True, linewrap=False) |
1356 res = dia.startProcess(cmd, args, projectPath) |
1353 res = dia.startProcess(cmd, args, projectPath) |
1357 if res: |
1354 if res: |
1358 dia.exec_() |
1355 dia.exec() |
1359 |
1356 |
1360 def __showRoutes(self): |
1357 def __showRoutes(self): |
1361 """ |
1358 """ |
1362 Private slot showing all URL dispatch routes. |
1359 Private slot showing all URL dispatch routes. |
1363 """ |
1360 """ |
1375 from .PyramidRoutesDialog import PyramidRoutesDialog |
1372 from .PyramidRoutesDialog import PyramidRoutesDialog |
1376 |
1373 |
1377 dia = PyramidRoutesDialog(self) |
1374 dia = PyramidRoutesDialog(self) |
1378 res = dia.start(projectPath) |
1375 res = dia.start(projectPath) |
1379 if res: |
1376 if res: |
1380 dia.exec_() |
1377 dia.exec() |
1381 |
1378 |
1382 def __showTweens(self): |
1379 def __showTweens(self): |
1383 """ |
1380 """ |
1384 Private slot showing all implicit and explicit tween objects. |
1381 Private slot showing all implicit and explicit tween objects. |
1385 """ |
1382 """ |
1399 args.append("development.ini") |
1396 args.append("development.ini") |
1400 |
1397 |
1401 dia = PyramidDialog(title, fixed=True, linewrap=False) |
1398 dia = PyramidDialog(title, fixed=True, linewrap=False) |
1402 res = dia.startProcess(cmd, args, projectPath) |
1399 res = dia.startProcess(cmd, args, projectPath) |
1403 if res: |
1400 if res: |
1404 dia.exec_() |
1401 dia.exec() |
1405 |
1402 |
1406 ################################################################## |
1403 ################################################################## |
1407 ## slots below implement documentation functions |
1404 ## slots below implement documentation functions |
1408 ################################################################## |
1405 ################################################################## |
1409 |
1406 |
1517 dia = PyramidDialog( |
1514 dia = PyramidDialog( |
1518 title, |
1515 title, |
1519 msgSuccess=self.tr("\nMessages extracted successfully.")) |
1516 msgSuccess=self.tr("\nMessages extracted successfully.")) |
1520 res = dia.startProcess(cmd, args, projectPath) |
1517 res = dia.startProcess(cmd, args, projectPath) |
1521 if res: |
1518 if res: |
1522 dia.exec_() |
1519 dia.exec() |
1523 self.__e5project.appendFile(os.path.join(projectPath, potFile)) |
1520 self.__e5project.appendFile(os.path.join(projectPath, potFile)) |
1524 |
1521 |
1525 def __projectLanguageAdded(self, code): |
1522 def __projectLanguageAdded(self, code): |
1526 """ |
1523 """ |
1527 Private slot handling the addition of a new language. |
1524 Private slot handling the addition of a new language. |
1551 title, |
1548 title, |
1552 msgSuccess=self.tr("\nMessage catalog initialized" |
1549 msgSuccess=self.tr("\nMessage catalog initialized" |
1553 " successfully.")) |
1550 " successfully.")) |
1554 res = dia.startProcess(cmd, args, projectPath) |
1551 res = dia.startProcess(cmd, args, projectPath) |
1555 if res: |
1552 if res: |
1556 dia.exec_() |
1553 dia.exec() |
1557 |
1554 |
1558 langFile = self.__e5project.getTranslationPattern().replace( |
1555 langFile = self.__e5project.getTranslationPattern().replace( |
1559 "%language%", code) |
1556 "%language%", code) |
1560 self.__e5project.appendFile(langFile) |
1557 self.__e5project.appendFile(langFile) |
1561 |
1558 |
1585 title, |
1582 title, |
1586 msgSuccess=self.tr("\nMessage catalogs compiled" |
1583 msgSuccess=self.tr("\nMessage catalogs compiled" |
1587 " successfully.")) |
1584 " successfully.")) |
1588 res = dia.startProcess(cmd, args, projectPath) |
1585 res = dia.startProcess(cmd, args, projectPath) |
1589 if res: |
1586 if res: |
1590 dia.exec_() |
1587 dia.exec() |
1591 |
1588 |
1592 for entry in os.walk(projectPath): |
1589 for entry in os.walk(projectPath): |
1593 for fileName in entry[2]: |
1590 for fileName in entry[2]: |
1594 fullName = os.path.join(entry[0], fileName) |
1591 fullName = os.path.join(entry[0], fileName) |
1595 if fullName.endswith('.mo'): |
1592 if fullName.endswith('.mo'): |
1637 title, |
1634 title, |
1638 msgSuccess=self.tr("\nMessage catalogs compiled" |
1635 msgSuccess=self.tr("\nMessage catalogs compiled" |
1639 " successfully.")) |
1636 " successfully.")) |
1640 res = dia.startBatchProcesses(argsLists, projectPath) |
1637 res = dia.startBatchProcesses(argsLists, projectPath) |
1641 if res: |
1638 if res: |
1642 dia.exec_() |
1639 dia.exec() |
1643 |
1640 |
1644 for entry in os.walk(self.__sitePath()): |
1641 for entry in os.walk(self.__sitePath()): |
1645 for fileName in entry[2]: |
1642 for fileName in entry[2]: |
1646 fullName = os.path.join(entry[0], fileName) |
1643 fullName = os.path.join(entry[0], fileName) |
1647 if fullName.endswith('.mo'): |
1644 if fullName.endswith('.mo'): |
1672 dia = PyramidDialog( |
1669 dia = PyramidDialog( |
1673 title, |
1670 title, |
1674 msgSuccess=self.tr("\nMessage catalogs updated successfully.")) |
1671 msgSuccess=self.tr("\nMessage catalogs updated successfully.")) |
1675 res = dia.startProcess(cmd, args, projectPath) |
1672 res = dia.startProcess(cmd, args, projectPath) |
1676 if res: |
1673 if res: |
1677 dia.exec_() |
1674 dia.exec() |
1678 |
1675 |
1679 def updateSelectedCatalogs(self, filenames): |
1676 def updateSelectedCatalogs(self, filenames): |
1680 """ |
1677 """ |
1681 Public method to update the message catalogs. |
1678 Public method to update the message catalogs. |
1682 |
1679 |
1717 dia = PyramidDialog( |
1714 dia = PyramidDialog( |
1718 title, |
1715 title, |
1719 msgSuccess=self.tr("\nMessage catalogs updated successfully.")) |
1716 msgSuccess=self.tr("\nMessage catalogs updated successfully.")) |
1720 res = dia.startBatchProcesses(argsLists, projectPath) |
1717 res = dia.startBatchProcesses(argsLists, projectPath) |
1721 if res: |
1718 if res: |
1722 dia.exec_() |
1719 dia.exec() |
1723 |
1720 |
1724 def openPOEditor(self, poFile): |
1721 def openPOEditor(self, poFile): |
1725 """ |
1722 """ |
1726 Public method to edit the given file in an external .po editor. |
1723 Public method to edit the given file in an external .po editor. |
1727 |
1724 |