556 } |
565 } |
557 |
566 |
558 self.vcs = self.initVCS() |
567 self.vcs = self.initVCS() |
559 |
568 |
560 self.__initVenvConfiguration() |
569 self.__initVenvConfiguration() |
|
570 |
|
571 def getProjectData(self, dataKey=None, default=None): |
|
572 """ |
|
573 Public method to get the data associated with the given data key. |
|
574 |
|
575 Note: If dataKey is None, a copy of the project data structure |
|
576 is returned. |
|
577 |
|
578 @param dataKey key of the data to get (defaults to None) |
|
579 @type str (optional) |
|
580 @param default default value for non-existent keys (defaults to None) |
|
581 @type Any (optional) |
|
582 @return requested data or None if the data key doesn't exist or |
|
583 a copy of the project data dictionary |
|
584 @rtype Any |
|
585 """ |
|
586 if dataKey is None: |
|
587 return copy.deepcopy(self.__pdata) |
|
588 |
|
589 try: |
|
590 return self.__pdata[dataKey] |
|
591 except KeyError: |
|
592 return default |
|
593 |
|
594 def setProjectData(self, data, dataKey=None): |
|
595 """ |
|
596 Public method to set data associated with the given data key in the project |
|
597 dictionary |
|
598 |
|
599 Note: If no data key is given or is None, the data must be a dictionary used |
|
600 to update the project data. |
|
601 |
|
602 @param data data to be set or a dictionary to update the project data |
|
603 @type Any |
|
604 @param dataKey key of the data to set (defaults to None) |
|
605 @type str (optional) |
|
606 """ |
|
607 if dataKey is None: |
|
608 self.__pdata.update(data) |
|
609 else: |
|
610 self.__pdata[dataKey] = data |
|
611 self.setDirty(True) |
561 |
612 |
562 def getData(self, category, key): |
613 def getData(self, category, key): |
563 """ |
614 """ |
564 Public method to get data out of the project data store. |
615 Public method to get data out of the project data store. |
565 |
616 |
606 ]: |
657 ]: |
607 return False |
658 return False |
608 |
659 |
609 # test for changes of data and save them in the project |
660 # test for changes of data and save them in the project |
610 # 1. there were none, now there are |
661 # 1. there were none, now there are |
611 if key not in self.pdata[category] and len(data) > 0: |
662 if key not in self.__pdata[category] and len(data) > 0: |
612 self.pdata[category][key] = copy.deepcopy(data) |
663 self.__pdata[category][key] = copy.deepcopy(data) |
613 self.setDirty(True) |
664 self.setDirty(True) |
614 # 2. there were some, now there aren't |
665 # 2. there were some, now there aren't |
615 elif key in self.pdata[category] and len(data) == 0: |
666 elif key in self.__pdata[category] and len(data) == 0: |
616 del self.pdata[category][key] |
667 del self.__pdata[category][key] |
617 self.setDirty(True) |
668 self.setDirty(True) |
618 # 3. there were some and still are |
669 # 3. there were some and still are |
619 elif key in self.pdata[category] and len(data) > 0: |
670 elif key in self.__pdata[category] and len(data) > 0: |
620 if data != self.pdata[category][key]: |
671 if data != self.__pdata[category][key]: |
621 self.pdata[category][key] = copy.deepcopy(data) |
672 self.__pdata[category][key] = copy.deepcopy(data) |
622 self.setDirty(True) |
673 self.setDirty(True) |
623 # 4. there were none and none are given |
674 # 4. there were none and none are given |
624 else: |
675 else: |
625 return False |
676 return False |
626 return True |
677 return True |
627 |
678 |
|
679 def getFileCategories(self): |
|
680 """ |
|
681 Public method to get the list of known file categories. |
|
682 |
|
683 @return list of known file categories |
|
684 @rtype list of str |
|
685 """ |
|
686 return self.__knownFileCategories[:] |
|
687 |
628 def initFileTypes(self): |
688 def initFileTypes(self): |
629 """ |
689 """ |
630 Public method to initialize the filetype associations with default |
690 Public method to initialize the filetype associations with default |
631 values. |
691 values. |
632 """ |
692 """ |
633 self.pdata["FILETYPES"] = { |
693 self.__pdata["FILETYPES"] = { |
634 "*.txt": "OTHERS", |
694 "*.txt": "OTHERS", |
635 "*.md": "OTHERS", |
695 "*.md": "OTHERS", |
636 "*.rst": "OTHERS", |
696 "*.rst": "OTHERS", |
637 "README": "OTHERS", |
697 "README": "OTHERS", |
638 "README.*": "OTHERS", |
698 "README.*": "OTHERS", |
643 "Makefile": "OTHERS", |
703 "Makefile": "OTHERS", |
644 } |
704 } |
645 |
705 |
646 # Sources |
706 # Sources |
647 sourceKey = ( |
707 sourceKey = ( |
648 "Mixed" if self.pdata["MIXEDLANGUAGE"] else self.pdata["PROGLANGUAGE"] |
708 "Mixed" if self.__pdata["MIXEDLANGUAGE"] else self.__pdata["PROGLANGUAGE"] |
649 ) |
709 ) |
650 for ext in self.__sourceExtensions(sourceKey): |
710 for ext in self.__sourceExtensions(sourceKey): |
651 self.pdata["FILETYPES"]["*{0}".format(ext)] = "SOURCES" |
711 self.__pdata["FILETYPES"]["*{0}".format(ext)] = "SOURCES" |
652 |
712 |
653 # IDL interfaces |
713 # IDL interfaces |
654 self.pdata["FILETYPES"]["*.idl"] = "INTERFACES" |
714 self.__pdata["FILETYPES"]["*.idl"] = "INTERFACES" |
655 |
715 |
656 # Protobuf Files |
716 # Protobuf Files |
657 self.pdata["FILETYPES"]["*.proto"] = "PROTOCOLS" |
717 self.__pdata["FILETYPES"]["*.proto"] = "PROTOCOLS" |
658 |
718 |
659 # Forms |
719 # Forms |
660 if self.pdata["PROJECTTYPE"] in [ |
720 if self.__pdata["PROJECTTYPE"] in [ |
661 "E7Plugin", |
721 "E7Plugin", |
662 "PyQt5", |
722 "PyQt5", |
663 "PyQt6", |
723 "PyQt6", |
664 "PySide2", |
724 "PySide2", |
665 "PySide6", |
725 "PySide6", |
666 ]: |
726 ]: |
667 self.pdata["FILETYPES"]["*.ui"] = "FORMS" |
727 self.__pdata["FILETYPES"]["*.ui"] = "FORMS" |
668 |
728 |
669 # Resources |
729 # Resources |
670 if self.pdata["PROJECTTYPE"] in [ |
730 if self.__pdata["PROJECTTYPE"] in [ |
671 "PyQt5", |
731 "PyQt5", |
672 "PyQt5C", |
732 "PyQt5C", |
673 "PySide2", |
733 "PySide2", |
674 "PySide2C", |
734 "PySide2C", |
675 "PySide6", |
735 "PySide6", |
676 "PySide6C", |
736 "PySide6C", |
677 ]: |
737 ]: |
678 self.pdata["FILETYPES"]["*.qrc"] = "RESOURCES" |
738 self.__pdata["FILETYPES"]["*.qrc"] = "RESOURCES" |
679 |
739 |
680 # Translations |
740 # Translations |
681 if self.pdata["PROJECTTYPE"] in [ |
741 if self.__pdata["PROJECTTYPE"] in [ |
682 "E7Plugin", |
742 "E7Plugin", |
683 "PyQt5", |
743 "PyQt5", |
684 "PyQt5C", |
744 "PyQt5C", |
685 "PyQt6", |
745 "PyQt6", |
686 "PyQt6C", |
746 "PyQt6C", |
687 "PySide2", |
747 "PySide2", |
688 "PySide2C", |
748 "PySide2C", |
689 "PySide6", |
749 "PySide6", |
690 "PySide6C", |
750 "PySide6C", |
691 ]: |
751 ]: |
692 self.pdata["FILETYPES"]["*.ts"] = "TRANSLATIONS" |
752 self.__pdata["FILETYPES"]["*.ts"] = "TRANSLATIONS" |
693 self.pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" |
753 self.__pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" |
694 |
754 |
695 # Project type specific ones |
755 # Project type specific ones |
696 with contextlib.suppress(KeyError): |
756 with contextlib.suppress(KeyError): |
697 if self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"]] is not None: |
757 if self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]] is not None: |
698 ftypes = self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"]]() |
758 ftypes = self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]]() |
699 self.pdata["FILETYPES"].update(ftypes) |
759 self.__pdata["FILETYPES"].update(ftypes) |
700 |
760 |
701 self.setDirty(True) |
761 self.setDirty(True) |
702 |
762 |
703 def updateFileTypes(self): |
763 def updateFileTypes(self): |
704 """ |
764 """ |
705 Public method to update the filetype associations with new default |
765 Public method to update the filetype associations with new default |
706 values. |
766 values. |
707 """ |
767 """ |
708 if self.pdata["PROJECTTYPE"] in [ |
768 if self.__pdata["PROJECTTYPE"] in [ |
709 "E7Plugin", |
769 "E7Plugin", |
710 "PyQt5", |
770 "PyQt5", |
711 "PyQt5C", |
771 "PyQt5C", |
712 "PyQt6", |
772 "PyQt6", |
713 "PyQt6C", |
773 "PyQt6C", |
714 "PySide2", |
774 "PySide2", |
715 "PySide2C", |
775 "PySide2C", |
716 "PySide6", |
776 "PySide6", |
717 "PySide6C", |
777 "PySide6C", |
718 ]: |
778 ]: |
719 if "*.ts" not in self.pdata["FILETYPES"]: |
779 if "*.ts" not in self.__pdata["FILETYPES"]: |
720 self.pdata["FILETYPES"]["*.ts"] = "TRANSLATIONS" |
780 self.__pdata["FILETYPES"]["*.ts"] = "TRANSLATIONS" |
721 if "*.qm" not in self.pdata["FILETYPES"]: |
781 if "*.qm" not in self.__pdata["FILETYPES"]: |
722 self.pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" |
782 self.__pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" |
723 with contextlib.suppress(KeyError): |
783 with contextlib.suppress(KeyError): |
724 if self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"]] is not None: |
784 if self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]] is not None: |
725 ftypes = self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"]]() |
785 ftypes = self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]]() |
726 for pattern, ftype in list(ftypes.items()): |
786 for pattern, ftype in list(ftypes.items()): |
727 if pattern not in self.pdata["FILETYPES"]: |
787 if pattern not in self.__pdata["FILETYPES"]: |
728 self.pdata["FILETYPES"][pattern] = ftype |
788 self.__pdata["FILETYPES"][pattern] = ftype |
729 self.setDirty(True) |
789 self.setDirty(True) |
730 |
790 |
731 def __loadRecent(self): |
791 def __loadRecent(self): |
732 """ |
792 """ |
733 Private method to load the recently opened project filenames. |
793 Private method to load the recently opened project filenames. |
917 |
977 |
918 self.name = os.path.splitext(os.path.basename(fn))[0] |
978 self.name = os.path.splitext(os.path.basename(fn))[0] |
919 |
979 |
920 # check, if the files of the project still exist in the |
980 # check, if the files of the project still exist in the |
921 # project directory |
981 # project directory |
922 self.__checkFilesExist("SOURCES") |
982 for fileCategory in self.__knownFileCategories: |
923 self.__checkFilesExist("FORMS") |
983 self.__checkFilesExist(fileCategory) |
924 self.__checkFilesExist("INTERFACES") |
984 ##self.__checkFilesExist("SOURCES") |
925 self.__checkFilesExist("PROTOCOLS") |
985 ##self.__checkFilesExist("FORMS") |
926 self.__checkFilesExist("TRANSLATIONS") |
986 ##self.__checkFilesExist("INTERFACES") |
927 self.__checkFilesExist("RESOURCES") |
987 ##self.__checkFilesExist("PROTOCOLS") |
928 self.__checkFilesExist("OTHERS") |
988 ##self.__checkFilesExist("TRANSLATIONS") |
|
989 ##self.__checkFilesExist("RESOURCES") |
|
990 ##self.__checkFilesExist("OTHERS") |
929 |
991 |
930 # get the names of subdirectories the files are stored in |
992 # get the names of subdirectories the files are stored in |
931 for fn in ( |
993 for fileCategory in [ |
932 self.pdata["SOURCES"] |
994 c for c in self.__knownFileCategories if c != "OTHERS" |
933 + self.pdata["FORMS"] |
995 ]: |
934 + self.pdata["INTERFACES"] |
996 for fn in self.__pdata[fileCategory]: |
935 + self.pdata["PROTOCOLS"] |
997 ##self.__pdata["SOURCES"] |
936 + self.pdata["RESOURCES"] |
998 ##+ self.__pdata["FORMS"] |
937 + self.pdata["TRANSLATIONS"] |
999 ##+ self.__pdata["INTERFACES"] |
938 ): |
1000 ##+ self.__pdata["PROTOCOLS"] |
939 dn = os.path.dirname(fn) |
1001 ##+ self.__pdata["RESOURCES"] |
940 if dn not in self.subdirs: |
1002 ##+ self.__pdata["TRANSLATIONS"] |
941 self.subdirs.append(dn) |
1003 ##): |
|
1004 dn = os.path.dirname(fn) |
|
1005 if dn not in self.subdirs: |
|
1006 self.subdirs.append(dn) |
942 |
1007 |
943 # get the names of other subdirectories |
1008 # get the names of other subdirectories |
944 for fn in self.pdata["OTHERS"]: |
1009 for fn in self.__pdata["OTHERS"]: |
945 dn = os.path.dirname(fn) |
1010 dn = os.path.dirname(fn) |
946 if dn not in self.otherssubdirs: |
1011 if dn not in self.otherssubdirs: |
947 self.otherssubdirs.append(dn) |
1012 self.otherssubdirs.append(dn) |
948 |
1013 |
949 return res |
1014 return res |
1456 """ |
1521 """ |
1457 Public method to get the translation pattern. |
1522 Public method to get the translation pattern. |
1458 |
1523 |
1459 @return translation pattern (string) |
1524 @return translation pattern (string) |
1460 """ |
1525 """ |
1461 return self.pdata["TRANSLATIONPATTERN"] |
1526 return self.__pdata["TRANSLATIONPATTERN"] |
1462 |
1527 |
1463 def setTranslationPattern(self, pattern): |
1528 def setTranslationPattern(self, pattern): |
1464 """ |
1529 """ |
1465 Public method to set the translation pattern. |
1530 Public method to set the translation pattern. |
1466 |
1531 |
1467 @param pattern translation pattern |
1532 @param pattern translation pattern |
1468 @type str |
1533 @type str |
1469 """ |
1534 """ |
1470 self.pdata["TRANSLATIONPATTERN"] = pattern |
1535 self.__pdata["TRANSLATIONPATTERN"] = pattern |
1471 |
1536 |
1472 def addLanguage(self): |
1537 def addLanguage(self): |
1473 """ |
1538 """ |
1474 Public slot used to add a language to the project. |
1539 Public slot used to add a language to the project. |
1475 """ |
1540 """ |
1476 from .AddLanguageDialog import AddLanguageDialog |
1541 from .AddLanguageDialog import AddLanguageDialog |
1477 |
1542 |
1478 if not self.pdata["TRANSLATIONPATTERN"]: |
1543 if not self.__pdata["TRANSLATIONPATTERN"]: |
1479 EricMessageBox.critical( |
1544 EricMessageBox.critical( |
1480 self.ui, |
1545 self.ui, |
1481 self.tr("Add Language"), |
1546 self.tr("Add Language"), |
1482 self.tr("You have to specify a translation pattern first."), |
1547 self.tr("You have to specify a translation pattern first."), |
1483 ) |
1548 ) |
1484 return |
1549 return |
1485 |
1550 |
1486 dlg = AddLanguageDialog(self.parent()) |
1551 dlg = AddLanguageDialog(self.parent()) |
1487 if dlg.exec() == QDialog.DialogCode.Accepted: |
1552 if dlg.exec() == QDialog.DialogCode.Accepted: |
1488 lang = dlg.getSelectedLanguage() |
1553 lang = dlg.getSelectedLanguage() |
1489 if self.pdata["PROJECTTYPE"] in [ |
1554 if self.__pdata["PROJECTTYPE"] in [ |
1490 "PyQt5", |
1555 "PyQt5", |
1491 "PyQt5C", |
1556 "PyQt5C", |
1492 "PyQt6", |
1557 "PyQt6", |
1493 "PyQt6C", |
1558 "PyQt6C", |
1494 "E7Plugin", |
1559 "E7Plugin", |
1495 "PySide2", |
1560 "PySide2", |
1496 "PySide2C", |
1561 "PySide2C", |
1497 "PySide6", |
1562 "PySide6", |
1498 "PySide6C", |
1563 "PySide6C", |
1499 ]: |
1564 ]: |
1500 langFile = self.pdata["TRANSLATIONPATTERN"].replace("%language%", lang) |
1565 langFile = self.__pdata["TRANSLATIONPATTERN"].replace( |
|
1566 "%language%", lang |
|
1567 ) |
1501 self.appendFile(langFile) |
1568 self.appendFile(langFile) |
1502 self.projectLanguageAddedByCode.emit(lang) |
1569 self.projectLanguageAddedByCode.emit(lang) |
1503 |
1570 |
1504 def __binaryTranslationFile(self, langFile): |
1571 def __binaryTranslationFile(self, langFile): |
1505 """ |
1572 """ |
1510 @return name of the binary translations file (string) |
1577 @return name of the binary translations file (string) |
1511 """ |
1578 """ |
1512 qmFile = "" |
1579 qmFile = "" |
1513 try: |
1580 try: |
1514 if ( |
1581 if ( |
1515 self.__binaryTranslationsCallbacks[self.pdata["PROJECTTYPE"]] |
1582 self.__binaryTranslationsCallbacks[self.__pdata["PROJECTTYPE"]] |
1516 is not None |
1583 is not None |
1517 ): |
1584 ): |
1518 qmFile = self.__binaryTranslationsCallbacks[self.pdata["PROJECTTYPE"]]( |
1585 qmFile = self.__binaryTranslationsCallbacks[ |
1519 langFile |
1586 self.__pdata["PROJECTTYPE"] |
1520 ) |
1587 ](langFile) |
1521 except KeyError: |
1588 except KeyError: |
1522 qmFile = langFile.replace(".ts", ".qm") |
1589 qmFile = langFile.replace(".ts", ".qm") |
1523 if qmFile == langFile: |
1590 if qmFile == langFile: |
1524 qmFile = "" |
1591 qmFile = "" |
1525 return qmFile |
1592 return qmFile |
1526 |
1593 |
1527 def checkLanguageFiles(self): |
1594 def checkLanguageFiles(self): |
1528 """ |
1595 """ |
1529 Public slot to check the language files after a release process. |
1596 Public slot to check the language files after a release process. |
1530 """ |
1597 """ |
1531 tbPath = self.pdata["TRANSLATIONSBINPATH"] |
1598 tbPath = self.__pdata["TRANSLATIONSBINPATH"] |
1532 for langFile in self.pdata["TRANSLATIONS"][:]: |
1599 for langFile in self.__pdata["TRANSLATIONS"][:]: |
1533 qmFile = self.__binaryTranslationFile(langFile) |
1600 qmFile = self.__binaryTranslationFile(langFile) |
1534 if qmFile: |
1601 if qmFile: |
1535 if qmFile not in self.pdata["TRANSLATIONS"] and os.path.exists( |
1602 if qmFile not in self.__pdata["TRANSLATIONS"] and os.path.exists( |
1536 os.path.join(self.ppath, qmFile) |
1603 os.path.join(self.ppath, qmFile) |
1537 ): |
1604 ): |
1538 self.appendFile(qmFile) |
1605 self.appendFile(qmFile) |
1539 if tbPath: |
1606 if tbPath: |
1540 qmFile = os.path.join(tbPath, os.path.basename(qmFile)) |
1607 qmFile = os.path.join(tbPath, os.path.basename(qmFile)) |
1541 if qmFile not in self.pdata["TRANSLATIONS"] and os.path.exists( |
1608 if qmFile not in self.__pdata["TRANSLATIONS"] and os.path.exists( |
1542 os.path.join(self.ppath, qmFile) |
1609 os.path.join(self.ppath, qmFile) |
1543 ): |
1610 ): |
1544 self.appendFile(qmFile) |
1611 self.appendFile(qmFile) |
1545 |
1612 |
1546 def removeLanguageFile(self, langFile): |
1613 def removeLanguageFile(self, langFile): |
1551 |
1618 |
1552 @param langFile the translation file to be removed (string) |
1619 @param langFile the translation file to be removed (string) |
1553 """ |
1620 """ |
1554 langFile = self.getRelativePath(langFile) |
1621 langFile = self.getRelativePath(langFile) |
1555 qmFile = self.__binaryTranslationFile(langFile) |
1622 qmFile = self.__binaryTranslationFile(langFile) |
1556 self.pdata["TRANSLATIONS"].remove(langFile) |
1623 self.__pdata["TRANSLATIONS"].remove(langFile) |
1557 self.__model.removeItem(langFile) |
1624 self.__model.removeItem(langFile) |
1558 if qmFile: |
1625 if qmFile: |
1559 with contextlib.suppress(ValueError): |
1626 with contextlib.suppress(ValueError): |
1560 if self.pdata["TRANSLATIONSBINPATH"]: |
1627 if self.__pdata["TRANSLATIONSBINPATH"]: |
1561 qmFile = self.getRelativePath( |
1628 qmFile = self.getRelativePath( |
1562 os.path.join( |
1629 os.path.join( |
1563 self.pdata["TRANSLATIONSBINPATH"], os.path.basename(qmFile) |
1630 self.__pdata["TRANSLATIONSBINPATH"], |
|
1631 os.path.basename(qmFile), |
1564 ) |
1632 ) |
1565 ) |
1633 ) |
1566 self.pdata["TRANSLATIONS"].remove(qmFile) |
1634 self.__pdata["TRANSLATIONS"].remove(qmFile) |
1567 self.__model.removeItem(qmFile) |
1635 self.__model.removeItem(qmFile) |
1568 self.setDirty(True) |
1636 self.setDirty(True) |
1569 |
1637 |
1570 def deleteLanguageFile(self, langFile): |
1638 def deleteLanguageFile(self, langFile): |
1571 """ |
1639 """ |
1644 filetype = "OTHERS" |
1713 filetype = "OTHERS" |
1645 bfn = os.path.basename(newfn) |
1714 bfn = os.path.basename(newfn) |
1646 if fnmatch.fnmatch(bfn, "*.ts") or fnmatch.fnmatch(bfn, "*.qm"): |
1715 if fnmatch.fnmatch(bfn, "*.ts") or fnmatch.fnmatch(bfn, "*.qm"): |
1647 filetype = "TRANSLATIONS" |
1716 filetype = "TRANSLATIONS" |
1648 else: |
1717 else: |
1649 for pattern in sorted(self.pdata["FILETYPES"].keys(), reverse=True): |
1718 for pattern in sorted(self.__pdata["FILETYPES"].keys(), reverse=True): |
1650 if fnmatch.fnmatch(bfn, pattern): |
1719 if fnmatch.fnmatch(bfn, pattern): |
1651 filetype = self.pdata["FILETYPES"][pattern] |
1720 filetype = self.__pdata["FILETYPES"][pattern] |
1652 break |
1721 break |
1653 |
1722 |
1654 if filetype == "__IGNORE__": |
1723 if filetype == "__IGNORE__": |
1655 return |
1724 return |
1656 |
1725 |
|
1726 # TODO: change this logic to be more generic (use fileCategory) |
1657 if filetype in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES"]: |
1727 if filetype in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES"]: |
1658 if filetype == "SOURCES": |
1728 if filetype == "SOURCES": |
1659 if newfn not in self.pdata["SOURCES"]: |
1729 if newfn not in self.__pdata["SOURCES"]: |
1660 self.pdata["SOURCES"].append(newfn) |
1730 self.__pdata["SOURCES"].append(newfn) |
1661 self.projectSourceAdded.emit(newfn) |
1731 self.projectSourceAdded.emit(newfn) |
1662 updateModel and self.__model.addNewItem("SOURCES", newfn) |
1732 updateModel and self.__model.addNewItem("SOURCES", newfn) |
1663 dirty = True |
1733 dirty = True |
1664 else: |
1734 else: |
1665 updateModel and self.repopulateItem(newfn) |
1735 updateModel and self.repopulateItem(newfn) |
1666 elif filetype == "FORMS": |
1736 elif filetype == "FORMS": |
1667 if newfn not in self.pdata["FORMS"]: |
1737 if newfn not in self.__pdata["FORMS"]: |
1668 self.pdata["FORMS"].append(newfn) |
1738 self.__pdata["FORMS"].append(newfn) |
1669 self.projectFormAdded.emit(newfn) |
1739 self.projectFormAdded.emit(newfn) |
1670 updateModel and self.__model.addNewItem("FORMS", newfn) |
1740 updateModel and self.__model.addNewItem("FORMS", newfn) |
1671 dirty = True |
1741 dirty = True |
1672 else: |
1742 else: |
1673 updateModel and self.repopulateItem(newfn) |
1743 updateModel and self.repopulateItem(newfn) |
1674 elif filetype == "INTERFACES": |
1744 elif filetype == "INTERFACES": |
1675 if newfn not in self.pdata["INTERFACES"]: |
1745 if newfn not in self.__pdata["INTERFACES"]: |
1676 self.pdata["INTERFACES"].append(newfn) |
1746 self.__pdata["INTERFACES"].append(newfn) |
1677 self.projectInterfaceAdded.emit(newfn) |
1747 self.projectInterfaceAdded.emit(newfn) |
1678 (updateModel and self.__model.addNewItem("INTERFACES", newfn)) |
1748 (updateModel and self.__model.addNewItem("INTERFACES", newfn)) |
1679 dirty = True |
1749 dirty = True |
1680 else: |
1750 else: |
1681 updateModel and self.repopulateItem(newfn) |
1751 updateModel and self.repopulateItem(newfn) |
1682 elif filetype == "PROTOCOLS": |
1752 elif filetype == "PROTOCOLS": |
1683 if newfn not in self.pdata["PROTOCOLS"]: |
1753 if newfn not in self.__pdata["PROTOCOLS"]: |
1684 self.pdata["PROTOCOLS"].append(newfn) |
1754 self.__pdata["PROTOCOLS"].append(newfn) |
1685 self.projectProtocolAdded.emit(newfn) |
1755 self.projectProtocolAdded.emit(newfn) |
1686 (updateModel and self.__model.addNewItem("PROTOCOLS", newfn)) |
1756 (updateModel and self.__model.addNewItem("PROTOCOLS", newfn)) |
1687 dirty = True |
1757 dirty = True |
1688 else: |
1758 else: |
1689 updateModel and self.repopulateItem(newfn) |
1759 updateModel and self.repopulateItem(newfn) |
1690 elif filetype == "RESOURCES": |
1760 elif filetype == "RESOURCES": |
1691 if newfn not in self.pdata["RESOURCES"]: |
1761 if newfn not in self.__pdata["RESOURCES"]: |
1692 self.pdata["RESOURCES"].append(newfn) |
1762 self.__pdata["RESOURCES"].append(newfn) |
1693 self.projectResourceAdded.emit(newfn) |
1763 self.projectResourceAdded.emit(newfn) |
1694 updateModel and self.__model.addNewItem("RESOURCES", newfn) |
1764 updateModel and self.__model.addNewItem("RESOURCES", newfn) |
1695 dirty = True |
1765 dirty = True |
1696 else: |
1766 else: |
1697 updateModel and self.repopulateItem(newfn) |
1767 updateModel and self.repopulateItem(newfn) |
1698 if newdir not in self.subdirs: |
1768 if newdir not in self.subdirs: |
1699 self.subdirs.append(newdir) |
1769 self.subdirs.append(newdir) |
1700 elif filetype == "TRANSLATIONS": |
1770 elif filetype == "TRANSLATIONS": |
1701 if newfn not in self.pdata["TRANSLATIONS"]: |
1771 if newfn not in self.__pdata["TRANSLATIONS"]: |
1702 self.pdata["TRANSLATIONS"].append(newfn) |
1772 self.__pdata["TRANSLATIONS"].append(newfn) |
1703 updateModel and self.__model.addNewItem("TRANSLATIONS", newfn) |
1773 updateModel and self.__model.addNewItem("TRANSLATIONS", newfn) |
1704 self.projectLanguageAdded.emit(newfn) |
1774 self.projectLanguageAdded.emit(newfn) |
1705 dirty = True |
1775 dirty = True |
1706 else: |
1776 else: |
1707 updateModel and self.repopulateItem(newfn) |
1777 updateModel and self.repopulateItem(newfn) |
1708 else: # filetype == "OTHERS" |
1778 else: # filetype == "OTHERS" |
1709 if newfn not in self.pdata["OTHERS"]: |
1779 if newfn not in self.__pdata["OTHERS"]: |
1710 self.pdata["OTHERS"].append(newfn) |
1780 self.__pdata["OTHERS"].append(newfn) |
1711 self.othersAdded(newfn, updateModel) |
1781 self.othersAdded(newfn, updateModel) |
1712 dirty = True |
1782 dirty = True |
1713 else: |
1783 else: |
1714 updateModel and self.repopulateItem(newfn) |
1784 updateModel and self.repopulateItem(newfn) |
1715 if newdir not in self.otherssubdirs: |
1785 if newdir not in self.otherssubdirs: |
2094 """Reason: {1}</p>""" |
2164 """Reason: {1}</p>""" |
2095 ).format(oldfn, str(msg)), |
2165 ).format(oldfn, str(msg)), |
2096 ) |
2166 ) |
2097 return False |
2167 return False |
2098 |
2168 |
2099 if ( |
2169 ##if ( |
2100 fn in self.pdata["SOURCES"] |
2170 ##fn in self.__pdata["SOURCES"] |
2101 or fn in self.pdata["FORMS"] |
2171 ##or fn in self.__pdata["FORMS"] |
2102 or fn in self.pdata["TRANSLATIONS"] |
2172 ##or fn in self.__pdata["TRANSLATIONS"] |
2103 or fn in self.pdata["INTERFACES"] |
2173 ##or fn in self.__pdata["INTERFACES"] |
2104 or fn in self.pdata["PROTOCOLS"] |
2174 ##or fn in self.__pdata["PROTOCOLS"] |
2105 or fn in self.pdata["RESOURCES"] |
2175 ##or fn in self.__pdata["RESOURCES"] |
2106 or fn in self.pdata["OTHERS"] |
2176 ##or fn in self.__pdata["OTHERS"] |
2107 ): |
2177 ##): |
|
2178 if any(fn in self.__pdata[category] for category in self.__knownFileCategories): |
2108 self.renameFileInPdata(oldfn, newfn, isSourceFile) |
2179 self.renameFileInPdata(oldfn, newfn, isSourceFile) |
2109 |
2180 |
2110 return True |
2181 return True |
2111 |
2182 |
2112 def renameFileInPdata(self, oldname, newname, isSourceFile=False): |
2183 def renameFileInPdata(self, oldname, newname, isSourceFile=False): |
2113 """ |
2184 """ |
2114 Public method to rename a file in the pdata structure. |
2185 Public method to rename a file in the __pdata structure. |
2115 |
2186 |
2116 @param oldname old filename (string) |
2187 @param oldname old filename (string) |
2117 @param newname new filename (string) |
2188 @param newname new filename (string) |
2118 @param isSourceFile flag indicating that this is a source file |
2189 @param isSourceFile flag indicating that this is a source file |
2119 even if it doesn't have the source extension (boolean) |
2190 even if it doesn't have the source extension (boolean) |
2159 """ |
2233 """ |
2160 reorganized = False |
2234 reorganized = False |
2161 |
2235 |
2162 # init data store for the reorganization |
2236 # init data store for the reorganization |
2163 newPdata = {} |
2237 newPdata = {} |
2164 for key in [ |
2238 ##for key in [ |
2165 "SOURCES", |
2239 ##"SOURCES", |
2166 "FORMS", |
2240 ##"FORMS", |
2167 "INTERFACES", |
2241 ##"INTERFACES", |
2168 "PROTOCOLS", |
2242 ##"PROTOCOLS", |
2169 "RESOURCES", |
2243 ##"RESOURCES", |
2170 "OTHERS", |
2244 ##"OTHERS", |
2171 "TRANSLATIONS", |
2245 ##"TRANSLATIONS", |
2172 ]: |
2246 ##]: |
2173 newPdata[key] = [] |
2247 for fileCategory in self.__knownFileCategories: |
|
2248 newPdata[fileCategory] = [] |
2174 |
2249 |
2175 # iterate over all files checking for a reassignment |
2250 # iterate over all files checking for a reassignment |
2176 for key in [ |
2251 ##for key in [ |
2177 "SOURCES", |
2252 ##"SOURCES", |
2178 "FORMS", |
2253 ##"FORMS", |
2179 "INTERFACES", |
2254 ##"INTERFACES", |
2180 "PROTOCOLS", |
2255 ##"PROTOCOLS", |
2181 "RESOURCES", |
2256 ##"RESOURCES", |
2182 "OTHERS", |
2257 ##"OTHERS", |
2183 "TRANSLATIONS", |
2258 ##"TRANSLATIONS", |
2184 ]: |
2259 ##]: |
2185 for fn in self.pdata[key][:]: |
2260 for fileCategory in self.__knownFileCategories: |
2186 filetype = key |
2261 for fn in self.__pdata[fileCategory][:]: |
|
2262 filetype = fileCategory |
2187 bfn = os.path.basename(fn) |
2263 bfn = os.path.basename(fn) |
2188 for pattern in sorted(self.pdata["FILETYPES"].keys(), reverse=True): |
2264 for pattern in sorted(self.__pdata["FILETYPES"].keys(), reverse=True): |
2189 if fnmatch.fnmatch(bfn, pattern): |
2265 if fnmatch.fnmatch(bfn, pattern): |
2190 filetype = self.pdata["FILETYPES"][pattern] |
2266 filetype = self.__pdata["FILETYPES"][pattern] |
2191 break |
2267 break |
2192 |
2268 |
2193 if filetype != "__IGNORE__": |
2269 if filetype != "__IGNORE__": |
2194 newPdata[filetype].append(fn) |
2270 newPdata[filetype].append(fn) |
2195 if filetype != key: |
2271 if filetype != fileCategory: |
2196 reorganized = True |
2272 reorganized = True |
2197 |
2273 |
2198 if reorganized: |
2274 if reorganized: |
2199 # copy the reorganized files back to the project |
2275 # copy the reorganized files back to the project |
2200 for key in [ |
2276 ##for key in [ |
2201 "SOURCES", |
2277 ##"SOURCES", |
2202 "FORMS", |
2278 ##"FORMS", |
2203 "INTERFACES", |
2279 ##"INTERFACES", |
2204 "PROTOCOLS", |
2280 ##"PROTOCOLS", |
2205 "RESOURCES", |
2281 ##"RESOURCES", |
2206 "OTHERS", |
2282 ##"OTHERS", |
2207 "TRANSLATIONS", |
2283 ##"TRANSLATIONS", |
2208 ]: |
2284 ##]: |
2209 self.pdata[key] = newPdata[key][:] |
2285 for fileCategory in self.__knownFileCategories: |
|
2286 self.__pdata[fileCategory] = newPdata[fileCategory][:] |
2210 |
2287 |
2211 # repopulate the model |
2288 # repopulate the model |
2212 self.__model.projectClosed(False) |
2289 self.__model.projectClosed(False) |
2213 self.__model.projectOpened() |
2290 self.__model.projectOpened() |
2214 |
2291 |
2219 @param olddn original directory name (string) |
2296 @param olddn original directory name (string) |
2220 @param newdn new directory name (string) |
2297 @param newdn new directory name (string) |
2221 """ |
2298 """ |
2222 olddn = self.getRelativePath(olddn) |
2299 olddn = self.getRelativePath(olddn) |
2223 newdn = self.getRelativePath(newdn) |
2300 newdn = self.getRelativePath(newdn) |
2224 for key in [ |
2301 ##for key in [ |
2225 "SOURCES", |
2302 ##"SOURCES", |
2226 "FORMS", |
2303 ##"FORMS", |
2227 "INTERFACES", |
2304 ##"INTERFACES", |
2228 "PROTOCOLS", |
2305 ##"PROTOCOLS", |
2229 "RESOURCES", |
2306 ##"RESOURCES", |
2230 "OTHERS", |
2307 ##"OTHERS", |
|
2308 ##]: |
|
2309 for fileCategory in [ |
|
2310 c for c in self.__knownFileCategories if c != "TRANSLATIONS" |
2231 ]: |
2311 ]: |
2232 for entry in self.pdata[key][:]: |
2312 for entry in self.__pdata[fileCategory][:]: |
2233 if entry.startswith(olddn): |
2313 if entry.startswith(olddn): |
2234 entry = entry.replace(olddn, newdn) |
2314 entry = entry.replace(olddn, newdn) |
2235 self.appendFile(os.path.join(self.ppath, entry), key == "SOURCES") |
2315 self.appendFile( |
|
2316 os.path.join(self.ppath, entry), fileCategory == "SOURCES" |
|
2317 ) |
2236 self.setDirty(True) |
2318 self.setDirty(True) |
2237 |
2319 |
2238 def moveDirectory(self, olddn, newdn): |
2320 def moveDirectory(self, olddn, newdn): |
2239 """ |
2321 """ |
2240 Public slot to move a directory. |
2322 Public slot to move a directory. |
2243 @param newdn new directory name (string) |
2325 @param newdn new directory name (string) |
2244 """ |
2326 """ |
2245 olddn = self.getRelativePath(olddn) |
2327 olddn = self.getRelativePath(olddn) |
2246 newdn = self.getRelativePath(newdn) |
2328 newdn = self.getRelativePath(newdn) |
2247 typeStrings = [] |
2329 typeStrings = [] |
2248 for key in [ |
2330 ##for key in [ |
2249 "SOURCES", |
2331 ##"SOURCES", |
2250 "FORMS", |
2332 ##"FORMS", |
2251 "INTERFACES", |
2333 ##"INTERFACES", |
2252 "PROTOCOLS", |
2334 ##"PROTOCOLS", |
2253 "RESOURCES", |
2335 ##"RESOURCES", |
2254 "OTHERS", |
2336 ##"OTHERS", |
|
2337 ##]: |
|
2338 for fileCategory in [ |
|
2339 c for c in self.__knownFileCategories if c != "TRANSLATIONS" |
2255 ]: |
2340 ]: |
2256 for entry in self.pdata[key][:]: |
2341 for entry in self.__pdata[fileCategory][:]: |
2257 if entry.startswith(olddn): |
2342 if entry.startswith(olddn): |
2258 if key not in typeStrings: |
2343 if fileCategory not in typeStrings: |
2259 typeStrings.append(key) |
2344 typeStrings.append(fileCategory) |
2260 self.pdata[key].remove(entry) |
2345 self.__pdata[fileCategory].remove(entry) |
2261 entry = entry.replace(olddn, newdn) |
2346 entry = entry.replace(olddn, newdn) |
2262 self.pdata[key].append(entry) |
2347 self.__pdata[fileCategory].append(entry) |
2263 if key == "OTHERS": |
2348 if fileCategory == "OTHERS": |
2264 if newdn not in self.otherssubdirs: |
2349 if newdn not in self.otherssubdirs: |
2265 self.otherssubdirs.append(newdn) |
2350 self.otherssubdirs.append(newdn) |
2266 else: |
2351 else: |
2267 if newdn not in self.subdirs: |
2352 if newdn not in self.subdirs: |
2268 self.subdirs.append(newdn) |
2353 self.subdirs.append(newdn) |
2287 @param updateModel flag indicating an update of the model is |
2372 @param updateModel flag indicating an update of the model is |
2288 requested (boolean) |
2373 requested (boolean) |
2289 """ |
2374 """ |
2290 fn = self.getRelativePath(fn) |
2375 fn = self.getRelativePath(fn) |
2291 dirty = True |
2376 dirty = True |
2292 if fn in self.pdata["SOURCES"]: |
2377 # TODO: change this logic to be more generic (use fileCategory) |
2293 self.pdata["SOURCES"].remove(fn) |
2378 if fn in self.__pdata["SOURCES"]: |
|
2379 self.__pdata["SOURCES"].remove(fn) |
2294 self.projectSourceRemoved.emit(fn) |
2380 self.projectSourceRemoved.emit(fn) |
2295 elif fn in self.pdata["FORMS"]: |
2381 elif fn in self.__pdata["FORMS"]: |
2296 self.pdata["FORMS"].remove(fn) |
2382 self.__pdata["FORMS"].remove(fn) |
2297 self.projectFormRemoved.emit(fn) |
2383 self.projectFormRemoved.emit(fn) |
2298 elif fn in self.pdata["INTERFACES"]: |
2384 elif fn in self.__pdata["INTERFACES"]: |
2299 self.pdata["INTERFACES"].remove(fn) |
2385 self.__pdata["INTERFACES"].remove(fn) |
2300 self.projectInterfaceRemoved.emit(fn) |
2386 self.projectInterfaceRemoved.emit(fn) |
2301 elif fn in self.pdata["PROTOCOLS"]: |
2387 elif fn in self.__pdata["PROTOCOLS"]: |
2302 self.pdata["PROTOCOLS"].remove(fn) |
2388 self.__pdata["PROTOCOLS"].remove(fn) |
2303 self.projectProtocolRemoved.emit(fn) |
2389 self.projectProtocolRemoved.emit(fn) |
2304 elif fn in self.pdata["RESOURCES"]: |
2390 elif fn in self.__pdata["RESOURCES"]: |
2305 self.pdata["RESOURCES"].remove(fn) |
2391 self.__pdata["RESOURCES"].remove(fn) |
2306 self.projectResourceRemoved.emit(fn) |
2392 self.projectResourceRemoved.emit(fn) |
2307 elif fn in self.pdata["OTHERS"]: |
2393 elif fn in self.__pdata["OTHERS"]: |
2308 self.pdata["OTHERS"].remove(fn) |
2394 self.__pdata["OTHERS"].remove(fn) |
2309 self.projectOthersRemoved.emit(fn) |
2395 self.projectOthersRemoved.emit(fn) |
2310 elif fn in self.pdata["TRANSLATIONS"]: |
2396 elif fn in self.__pdata["TRANSLATIONS"]: |
2311 self.pdata["TRANSLATIONS"].remove(fn) |
2397 self.__pdata["TRANSLATIONS"].remove(fn) |
2312 self.projectLanguageRemoved.emit(fn) |
2398 self.projectLanguageRemoved.emit(fn) |
2313 else: |
2399 else: |
2314 dirty = False |
2400 dirty = False |
2315 updateModel and self.__model.removeItem(fn) |
2401 updateModel and self.__model.removeItem(fn) |
2316 if dirty: |
2402 if dirty: |
2429 |
2516 |
2430 @param fn filename to be checked (string) |
2517 @param fn filename to be checked (string) |
2431 @return flag indicating, if the project contains the file (boolean) |
2518 @return flag indicating, if the project contains the file (boolean) |
2432 """ |
2519 """ |
2433 fn = self.getRelativePath(fn) |
2520 fn = self.getRelativePath(fn) |
2434 return ( |
2521 return any( |
2435 fn in self.pdata["SOURCES"] |
2522 fn in self.__pdata[category] |
2436 or fn in self.pdata["FORMS"] |
2523 for category in self.__knownFileCategories |
2437 or fn in self.pdata["INTERFACES"] |
2524 if category != "TRANSLATIONS" |
2438 or fn in self.pdata["PROTOCOLS"] |
2525 ) |
2439 or fn in self.pdata["RESOURCES"] |
2526 ##fn in self.__pdata["SOURCES"] |
2440 or fn in self.pdata["OTHERS"] |
2527 ##or fn in self.__pdata["FORMS"] |
2441 ) |
2528 ##or fn in self.__pdata["INTERFACES"] |
|
2529 ##or fn in self.__pdata["PROTOCOLS"] |
|
2530 ##or fn in self.__pdata["RESOURCES"] |
|
2531 ##or fn in self.__pdata["OTHERS"] |
|
2532 ##) |
2442 |
2533 |
2443 def createNewProject(self): |
2534 def createNewProject(self): |
2444 """ |
2535 """ |
2445 Public slot to built a new project. |
2536 Public slot to built a new project. |
2446 |
2537 |
2477 self.menuCheckAct.setEnabled(True) |
2568 self.menuCheckAct.setEnabled(True) |
2478 self.menuShowAct.setEnabled(True) |
2569 self.menuShowAct.setEnabled(True) |
2479 self.menuDiagramAct.setEnabled(True) |
2570 self.menuDiagramAct.setEnabled(True) |
2480 self.menuApidocAct.setEnabled(True) |
2571 self.menuApidocAct.setEnabled(True) |
2481 self.menuPackagersAct.setEnabled(True) |
2572 self.menuPackagersAct.setEnabled(True) |
2482 self.pluginGrp.setEnabled(self.pdata["PROJECTTYPE"] in ["E7Plugin"]) |
2573 self.pluginGrp.setEnabled(self.__pdata["PROJECTTYPE"] in ["E7Plugin"]) |
2483 self.addLanguageAct.setEnabled(bool(self.pdata["TRANSLATIONPATTERN"])) |
2574 self.addLanguageAct.setEnabled(bool(self.__pdata["TRANSLATIONPATTERN"])) |
2484 self.makeGrp.setEnabled(self.pdata["MAKEPARAMS"]["MakeEnabled"]) |
2575 self.makeGrp.setEnabled(self.__pdata["MAKEPARAMS"]["MakeEnabled"]) |
2485 self.menuMakeAct.setEnabled(self.pdata["MAKEPARAMS"]["MakeEnabled"]) |
2576 self.menuMakeAct.setEnabled(self.__pdata["MAKEPARAMS"]["MakeEnabled"]) |
2486 self.menuOtherToolsAct.setEnabled(True) |
2577 self.menuOtherToolsAct.setEnabled(True) |
2487 self.menuFormattingAct.setEnabled(True) |
2578 self.menuFormattingAct.setEnabled(True) |
2488 |
2579 |
2489 self.projectAboutToBeCreated.emit() |
2580 self.projectAboutToBeCreated.emit() |
2490 |
2581 |
2519 self.vcs = self.initVCS() |
2610 self.vcs = self.initVCS() |
2520 return |
2611 return |
2521 |
2612 |
2522 # create an empty __init__.py file to make it a Python package |
2613 # create an empty __init__.py file to make it a Python package |
2523 # (only for Python and Python3) |
2614 # (only for Python and Python3) |
2524 if self.pdata["PROGLANGUAGE"] in ["Python3", "MicroPython"]: |
2615 if self.__pdata["PROGLANGUAGE"] in ["Python3", "MicroPython"]: |
2525 fn = os.path.join(self.ppath, "__init__.py") |
2616 fn = os.path.join(self.ppath, "__init__.py") |
2526 with open(fn, "w", encoding="utf-8"): |
2617 with open(fn, "w", encoding="utf-8"): |
2527 pass |
2618 pass |
2528 self.appendFile(fn, True) |
2619 self.appendFile(fn, True) |
2529 |
2620 |
2530 # create an empty main script file, if a name was given |
2621 # create an empty main script file, if a name was given |
2531 if self.pdata["MAINSCRIPT"]: |
2622 if self.__pdata["MAINSCRIPT"]: |
2532 if not os.path.isabs(self.pdata["MAINSCRIPT"]): |
2623 if not os.path.isabs(self.__pdata["MAINSCRIPT"]): |
2533 ms = os.path.join(self.ppath, self.pdata["MAINSCRIPT"]) |
2624 ms = os.path.join(self.ppath, self.__pdata["MAINSCRIPT"]) |
2534 else: |
2625 else: |
2535 ms = self.pdata["MAINSCRIPT"] |
2626 ms = self.__pdata["MAINSCRIPT"] |
2536 os.makedirs(os.path.dirname(ms), exist_ok=True) |
2627 os.makedirs(os.path.dirname(ms), exist_ok=True) |
2537 with open(ms, "w"): |
2628 with open(ms, "w"): |
2538 pass |
2629 pass |
2539 self.appendFile(ms, True) |
2630 self.appendFile(ms, True) |
2540 |
2631 |
2541 if self.pdata["MAKEPARAMS"]["MakeEnabled"]: |
2632 if self.__pdata["MAKEPARAMS"]["MakeEnabled"]: |
2542 mf = self.pdata["MAKEPARAMS"]["MakeFile"] |
2633 mf = self.__pdata["MAKEPARAMS"]["MakeFile"] |
2543 if mf: |
2634 if mf: |
2544 if not os.path.isabs(mf): |
2635 if not os.path.isabs(mf): |
2545 mf = os.path.join(self.ppath, mf) |
2636 mf = os.path.join(self.ppath, mf) |
2546 else: |
2637 else: |
2547 mf = os.path.join(self.ppath, Project.DefaultMakefile) |
2638 mf = os.path.join(self.ppath, Project.DefaultMakefile) |
2553 tpd = os.path.join(self.ppath, self.translationsRoot) |
2644 tpd = os.path.join(self.ppath, self.translationsRoot) |
2554 if not self.translationsRoot.endswith(os.sep): |
2645 if not self.translationsRoot.endswith(os.sep): |
2555 tpd = os.path.dirname(tpd) |
2646 tpd = os.path.dirname(tpd) |
2556 if not os.path.isdir(tpd): |
2647 if not os.path.isdir(tpd): |
2557 os.makedirs(tpd, exist_ok=True) |
2648 os.makedirs(tpd, exist_ok=True) |
2558 if self.pdata["TRANSLATIONSBINPATH"]: |
2649 if self.__pdata["TRANSLATIONSBINPATH"]: |
2559 tpd = os.path.join(self.ppath, self.pdata["TRANSLATIONSBINPATH"]) |
2650 tpd = os.path.join(self.ppath, self.__pdata["TRANSLATIONSBINPATH"]) |
2560 if not os.path.isdir(tpd): |
2651 if not os.path.isdir(tpd): |
2561 os.makedirs(tpd, exist_ok=True) |
2652 os.makedirs(tpd, exist_ok=True) |
2562 |
2653 |
2563 # create management directory if not present |
2654 # create management directory if not present |
2564 self.createProjectManagementDir() |
2655 self.createProjectManagementDir() |
2735 False, |
2826 False, |
2736 ) |
2827 ) |
2737 if ok and vcsSelected != self.tr("None"): |
2828 if ok and vcsSelected != self.tr("None"): |
2738 for vcsSystem, vcsSystemDisplay in vcsSystemsDict.items(): |
2829 for vcsSystem, vcsSystemDisplay in vcsSystemsDict.items(): |
2739 if vcsSystemDisplay == vcsSelected: |
2830 if vcsSystemDisplay == vcsSelected: |
2740 self.pdata["VCS"] = vcsSystem |
2831 self.__pdata["VCS"] = vcsSystem |
2741 break |
2832 break |
2742 else: |
2833 else: |
2743 self.pdata["VCS"] = "None" |
2834 self.__pdata["VCS"] = "None" |
2744 else: |
2835 else: |
2745 self.pdata["VCS"] = "None" |
2836 self.__pdata["VCS"] = "None" |
2746 self.vcs = self.initVCS() |
2837 self.vcs = self.initVCS() |
2747 if self.vcs is not None: |
2838 if self.vcs is not None: |
2748 vcsdlg = self.vcs.vcsOptionsDialog(self, self.name) |
2839 vcsdlg = self.vcs.vcsOptionsDialog(self, self.name) |
2749 if vcsdlg.exec() == QDialog.DialogCode.Accepted: |
2840 if vcsdlg.exec() == QDialog.DialogCode.Accepted: |
2750 vcsDataDict = vcsdlg.getData() |
2841 vcsDataDict = vcsdlg.getData() |
2751 else: |
2842 else: |
2752 self.pdata["VCS"] = "None" |
2843 self.__pdata["VCS"] = "None" |
2753 self.vcs = self.initVCS() |
2844 self.vcs = self.initVCS() |
2754 self.setDirty(True) |
2845 self.setDirty(True) |
2755 if self.vcs is not None: |
2846 if self.vcs is not None: |
2756 # edit VCS command options |
2847 # edit VCS command options |
2757 if self.vcs.vcsSupportCommandOptions(): |
2848 if self.vcs.vcsSupportCommandOptions(): |
2849 ), |
2940 ), |
2850 QLineEdit.EchoMode.Normal, |
2941 QLineEdit.EchoMode.Normal, |
2851 tslist[0], |
2942 tslist[0], |
2852 ) |
2943 ) |
2853 if pattern: |
2944 if pattern: |
2854 self.pdata["TRANSLATIONPATTERN"] = pattern |
2945 self.__pdata["TRANSLATIONPATTERN"] = pattern |
2855 if self.pdata["TRANSLATIONPATTERN"]: |
2946 if self.__pdata["TRANSLATIONPATTERN"]: |
2856 self.pdata["TRANSLATIONPATTERN"] = self.getRelativePath( |
2947 self.__pdata["TRANSLATIONPATTERN"] = self.getRelativePath( |
2857 self.pdata["TRANSLATIONPATTERN"] |
2948 self.__pdata["TRANSLATIONPATTERN"] |
2858 ) |
2949 ) |
2859 pattern = self.pdata["TRANSLATIONPATTERN"].replace( |
2950 pattern = self.__pdata["TRANSLATIONPATTERN"].replace( |
2860 "%language%", "*" |
2951 "%language%", "*" |
2861 ) |
2952 ) |
2862 for ts in tslist: |
2953 for ts in tslist: |
2863 if fnmatch.fnmatch(ts, pattern): |
2954 if fnmatch.fnmatch(ts, pattern): |
2864 self.pdata["TRANSLATIONS"].append(ts) |
2955 self.__pdata["TRANSLATIONS"].append(ts) |
2865 self.projectLanguageAdded.emit(ts) |
2956 self.projectLanguageAdded.emit(ts) |
2866 if self.pdata["TRANSLATIONSBINPATH"]: |
2957 if self.__pdata["TRANSLATIONSBINPATH"]: |
2867 tpd = os.path.join( |
2958 tpd = os.path.join( |
2868 self.ppath, self.pdata["TRANSLATIONSBINPATH"] |
2959 self.ppath, self.__pdata["TRANSLATIONSBINPATH"] |
2869 ) |
2960 ) |
2870 pattern = os.path.basename( |
2961 pattern = os.path.basename( |
2871 self.pdata["TRANSLATIONPATTERN"] |
2962 self.__pdata["TRANSLATIONPATTERN"] |
2872 ).replace("%language%", "*") |
2963 ).replace("%language%", "*") |
2873 pattern = self.__binaryTranslationFile(pattern) |
2964 pattern = self.__binaryTranslationFile(pattern) |
2874 qmlist = Utilities.direntries(tpd, True, pattern) |
2965 qmlist = Utilities.direntries(tpd, True, pattern) |
2875 for qm in qmlist: |
2966 for qm in qmlist: |
2876 self.pdata["TRANSLATIONS"].append(qm) |
2967 self.__pdata["TRANSLATIONS"].append(qm) |
2877 self.projectLanguageAdded.emit(qm) |
2968 self.projectLanguageAdded.emit(qm) |
2878 if not self.pdata["MAINSCRIPT"] and bool(mainscriptname): |
2969 if not self.__pdata["MAINSCRIPT"] and bool(mainscriptname): |
2879 if self.pdata["PROGLANGUAGE"] in ["Python3", "MicroPython"]: |
2970 if self.__pdata["PROGLANGUAGE"] in ["Python3", "MicroPython"]: |
2880 self.pdata["MAINSCRIPT"] = "{0}.py".format(mainscriptname) |
2971 self.__pdata["MAINSCRIPT"] = "{0}.py".format(mainscriptname) |
2881 elif self.pdata["PROGLANGUAGE"] == "Ruby": |
2972 elif self.__pdata["PROGLANGUAGE"] == "Ruby": |
2882 self.pdata["MAINSCRIPT"] = "{0}.rb".format(mainscriptname) |
2973 self.__pdata["MAINSCRIPT"] = "{0}.rb".format(mainscriptname) |
2883 self.setDirty(True) |
2974 self.setDirty(True) |
2884 |
2975 |
2885 def __showProperties(self): |
2976 def __showProperties(self): |
2886 """ |
2977 """ |
2887 Private slot to display the properties dialog. |
2978 Private slot to display the properties dialog. |
2888 """ |
2979 """ |
2889 from .PropertiesDialog import PropertiesDialog |
2980 from .PropertiesDialog import PropertiesDialog |
2890 |
2981 |
2891 dlg = PropertiesDialog(self, False) |
2982 dlg = PropertiesDialog(self, False) |
2892 if dlg.exec() == QDialog.DialogCode.Accepted: |
2983 if dlg.exec() == QDialog.DialogCode.Accepted: |
2893 projectType = self.pdata["PROJECTTYPE"] |
2984 projectType = self.__pdata["PROJECTTYPE"] |
2894 dlg.storeData() |
2985 dlg.storeData() |
2895 self.setDirty(True) |
2986 self.setDirty(True) |
2896 if self.pdata["MAINSCRIPT"]: |
2987 if self.__pdata["MAINSCRIPT"]: |
2897 if not os.path.isabs(self.pdata["MAINSCRIPT"]): |
2988 if not os.path.isabs(self.__pdata["MAINSCRIPT"]): |
2898 ms = os.path.join(self.ppath, self.pdata["MAINSCRIPT"]) |
2989 ms = os.path.join(self.ppath, self.__pdata["MAINSCRIPT"]) |
2899 else: |
2990 else: |
2900 ms = self.pdata["MAINSCRIPT"] |
2991 ms = self.__pdata["MAINSCRIPT"] |
2901 if os.path.exists(ms): |
2992 if os.path.exists(ms): |
2902 self.appendFile(ms) |
2993 self.appendFile(ms) |
2903 |
2994 |
2904 if self.pdata["MAKEPARAMS"]["MakeEnabled"]: |
2995 if self.__pdata["MAKEPARAMS"]["MakeEnabled"]: |
2905 mf = self.pdata["MAKEPARAMS"]["MakeFile"] |
2996 mf = self.__pdata["MAKEPARAMS"]["MakeFile"] |
2906 if mf: |
2997 if mf: |
2907 if not os.path.isabs(mf): |
2998 if not os.path.isabs(mf): |
2908 mf = os.path.join(self.ppath, mf) |
2999 mf = os.path.join(self.ppath, mf) |
2909 else: |
3000 else: |
2910 mf = os.path.join(self.ppath, Project.DefaultMakefile) |
3001 mf = os.path.join(self.ppath, Project.DefaultMakefile) |
2936 if not os.path.isdir(tp): |
3027 if not os.path.isdir(tp): |
2937 os.makedirs(tp) |
3028 os.makedirs(tp) |
2938 if tp != self.ppath and tp not in self.subdirs: |
3029 if tp != self.ppath and tp not in self.subdirs: |
2939 self.subdirs.append(tp) |
3030 self.subdirs.append(tp) |
2940 |
3031 |
2941 if self.pdata["TRANSLATIONSBINPATH"]: |
3032 if self.__pdata["TRANSLATIONSBINPATH"]: |
2942 tp = os.path.join(self.ppath, self.pdata["TRANSLATIONSBINPATH"]) |
3033 tp = os.path.join(self.ppath, self.__pdata["TRANSLATIONSBINPATH"]) |
2943 if not os.path.isdir(tp): |
3034 if not os.path.isdir(tp): |
2944 os.makedirs(tp) |
3035 os.makedirs(tp) |
2945 if tp != self.ppath and tp not in self.subdirs: |
3036 if tp != self.ppath and tp not in self.subdirs: |
2946 self.subdirs.append(tp) |
3037 self.subdirs.append(tp) |
2947 |
3038 |
2948 self.pluginGrp.setEnabled(self.pdata["PROJECTTYPE"] in ["E7Plugin"]) |
3039 self.pluginGrp.setEnabled(self.__pdata["PROJECTTYPE"] in ["E7Plugin"]) |
2949 |
3040 |
2950 self.__model.projectPropertiesChanged() |
3041 self.__model.projectPropertiesChanged() |
2951 self.projectPropertiesChanged.emit() |
3042 self.projectPropertiesChanged.emit() |
2952 |
3043 |
2953 if self.pdata["PROJECTTYPE"] != projectType: |
3044 if self.__pdata["PROJECTTYPE"] != projectType: |
2954 self.__reorganizeFiles() |
3045 self.__reorganizeFiles() |
2955 |
3046 |
2956 if self.pdata["EMBEDDED_VENV"] and not self.__findEmbeddedEnvironment(): |
3047 if self.__pdata["EMBEDDED_VENV"] and not self.__findEmbeddedEnvironment(): |
2957 self.__createEmbeddedEnvironment() |
3048 self.__createEmbeddedEnvironment() |
2958 |
3049 |
2959 def __showUserProperties(self): |
3050 def __showUserProperties(self): |
2960 """ |
3051 """ |
2961 Private slot to display the user specific properties dialog. |
3052 Private slot to display the user specific properties dialog. |
2962 """ |
3053 """ |
2963 from .UserPropertiesDialog import UserPropertiesDialog |
3054 from .UserPropertiesDialog import UserPropertiesDialog |
2964 |
3055 |
2965 vcsSystem = self.pdata["VCS"] or None |
3056 vcsSystem = self.__pdata["VCS"] or None |
2966 vcsSystemOverride = self.pudata["VCSOVERRIDE"] or None |
3057 vcsSystemOverride = self.pudata["VCSOVERRIDE"] or None |
2967 |
3058 |
2968 dlg = UserPropertiesDialog(self) |
3059 dlg = UserPropertiesDialog(self) |
2969 if dlg.exec() == QDialog.DialogCode.Accepted: |
3060 if dlg.exec() == QDialog.DialogCode.Accepted: |
2970 dlg.storeData() |
3061 dlg.storeData() |
2971 |
3062 |
2972 if ( |
3063 if ( |
2973 (self.pdata["VCS"] and self.pdata["VCS"] != vcsSystem) |
3064 (self.__pdata["VCS"] and self.__pdata["VCS"] != vcsSystem) |
2974 or ( |
3065 or ( |
2975 self.pudata["VCSOVERRIDE"] |
3066 self.pudata["VCSOVERRIDE"] |
2976 and self.pudata["VCSOVERRIDE"] != vcsSystemOverride |
3067 and self.pudata["VCSOVERRIDE"] != vcsSystemOverride |
2977 ) |
3068 ) |
2978 or (vcsSystemOverride is not None and not self.pudata["VCSOVERRIDE"]) |
3069 or (vcsSystemOverride is not None and not self.pudata["VCSOVERRIDE"]) |
3046 @param filename filename used to determine the associated lexer |
3137 @param filename filename used to determine the associated lexer |
3047 language (string) |
3138 language (string) |
3048 @return the requested lexer language (string) |
3139 @return the requested lexer language (string) |
3049 """ |
3140 """ |
3050 # try user settings first |
3141 # try user settings first |
3051 for pattern, language in list(self.pdata["LEXERASSOCS"].items()): |
3142 for pattern, language in list(self.__pdata["LEXERASSOCS"].items()): |
3052 if fnmatch.fnmatch(filename, pattern): |
3143 if fnmatch.fnmatch(filename, pattern): |
3053 return language |
3144 return language |
3054 |
3145 |
3055 # try project type specific defaults next |
3146 # try project type specific defaults next |
3056 projectType = self.pdata["PROJECTTYPE"] |
3147 projectType = self.__pdata["PROJECTTYPE"] |
3057 with contextlib.suppress(KeyError): |
3148 with contextlib.suppress(KeyError): |
3058 if self.__lexerAssociationCallbacks[projectType] is not None: |
3149 if self.__lexerAssociationCallbacks[projectType] is not None: |
3059 return self.__lexerAssociationCallbacks[projectType](filename) |
3150 return self.__lexerAssociationCallbacks[projectType](filename) |
3060 |
3151 |
3061 # return empty string to signal to use the global setting |
3152 # return empty string to signal to use the global setting |
3178 self.menuCheckAct.setEnabled(True) |
3269 self.menuCheckAct.setEnabled(True) |
3179 self.menuShowAct.setEnabled(True) |
3270 self.menuShowAct.setEnabled(True) |
3180 self.menuDiagramAct.setEnabled(True) |
3271 self.menuDiagramAct.setEnabled(True) |
3181 self.menuApidocAct.setEnabled(True) |
3272 self.menuApidocAct.setEnabled(True) |
3182 self.menuPackagersAct.setEnabled(True) |
3273 self.menuPackagersAct.setEnabled(True) |
3183 self.pluginGrp.setEnabled(self.pdata["PROJECTTYPE"] in ["E7Plugin"]) |
3274 self.pluginGrp.setEnabled( |
|
3275 self.__pdata["PROJECTTYPE"] in ["E7Plugin"] |
|
3276 ) |
3184 self.addLanguageAct.setEnabled( |
3277 self.addLanguageAct.setEnabled( |
3185 bool(self.pdata["TRANSLATIONPATTERN"]) |
3278 bool(self.__pdata["TRANSLATIONPATTERN"]) |
3186 ) |
3279 ) |
3187 self.makeGrp.setEnabled(self.pdata["MAKEPARAMS"]["MakeEnabled"]) |
3280 self.makeGrp.setEnabled(self.__pdata["MAKEPARAMS"]["MakeEnabled"]) |
3188 self.menuMakeAct.setEnabled(self.pdata["MAKEPARAMS"]["MakeEnabled"]) |
3281 self.menuMakeAct.setEnabled( |
|
3282 self.__pdata["MAKEPARAMS"]["MakeEnabled"] |
|
3283 ) |
3189 self.menuOtherToolsAct.setEnabled(True) |
3284 self.menuOtherToolsAct.setEnabled(True) |
3190 self.menuFormattingAct.setEnabled(True) |
3285 self.menuFormattingAct.setEnabled(True) |
3191 |
3286 |
3192 # open a project debugger properties file being quiet |
3287 # open a project debugger properties file being quiet |
3193 # about errors |
3288 # about errors |
3194 if Preferences.getProject("AutoLoadDbgProperties"): |
3289 if Preferences.getProject("AutoLoadDbgProperties"): |
3195 self.__readDebugProperties(True) |
3290 self.__readDebugProperties(True) |
3196 |
3291 |
3197 self.__model.projectOpened() |
3292 self.__model.projectOpened() |
3198 |
3293 |
3199 if self.pdata["EMBEDDED_VENV"]: |
3294 if self.__pdata["EMBEDDED_VENV"]: |
3200 envPath = self.__findEmbeddedEnvironment() |
3295 envPath = self.__findEmbeddedEnvironment() |
3201 if bool(envPath): |
3296 if bool(envPath): |
3202 self.__loadEnvironmentConfiguration() |
3297 self.__loadEnvironmentConfiguration() |
3203 if not bool( |
3298 if not bool( |
3204 self.__venvConfiguration["interpreter"] |
3299 self.__venvConfiguration["interpreter"] |
3581 @type boolean |
3676 @type boolean |
3582 @return list of file names |
3677 @return list of file names |
3583 @rtype list of str |
3678 @rtype list of str |
3584 @exception ValueError raised when an unsupported file type is given |
3679 @exception ValueError raised when an unsupported file type is given |
3585 """ |
3680 """ |
3586 if fileType not in [ |
3681 if fileType not in self.__knownFileCategories: |
3587 "SOURCES", |
3682 ##[ |
3588 "FORMS", |
3683 ##"SOURCES", |
3589 "RESOURCES", |
3684 ##"FORMS", |
3590 "INTERFACES", |
3685 ##"RESOURCES", |
3591 "PROTOCOLS", |
3686 ##"INTERFACES", |
3592 "OTHERS", |
3687 ##"PROTOCOLS", |
3593 "TRANSLATIONS", |
3688 ##"OTHERS", |
3594 ]: |
3689 ##"TRANSLATIONS", |
|
3690 ##]: |
3595 raise ValueError("Given file type has incorrect value.") |
3691 raise ValueError("Given file type has incorrect value.") |
3596 |
3692 |
3597 if normalized: |
3693 if normalized: |
3598 return [os.path.join(self.ppath, fn) for fn in self.pdata[fileType]] |
3694 return [os.path.join(self.ppath, fn) for fn in self.__pdata[fileType]] |
3599 else: |
3695 else: |
3600 return self.pdata[fileType] |
3696 return self.__pdata[fileType] |
3601 |
3697 |
3602 def getProjectType(self): |
3698 def getProjectType(self): |
3603 """ |
3699 """ |
3604 Public method to get the type of the project. |
3700 Public method to get the type of the project. |
3605 |
3701 |
3606 @return UI type of the project (string) |
3702 @return UI type of the project (string) |
3607 """ |
3703 """ |
3608 return self.pdata["PROJECTTYPE"] |
3704 return self.__pdata["PROJECTTYPE"] |
3609 |
3705 |
3610 def getProjectLanguage(self): |
3706 def getProjectLanguage(self): |
3611 """ |
3707 """ |
3612 Public method to get the project's programming language. |
3708 Public method to get the project's programming language. |
3613 |
3709 |
3614 @return programming language (string) |
3710 @return programming language (string) |
3615 """ |
3711 """ |
3616 return self.pdata["PROGLANGUAGE"] |
3712 return self.__pdata["PROGLANGUAGE"] |
3617 |
3713 |
3618 def isMixedLanguageProject(self): |
3714 def isMixedLanguageProject(self): |
3619 """ |
3715 """ |
3620 Public method to check, if this is a mixed language project. |
3716 Public method to check, if this is a mixed language project. |
3621 |
3717 |
3622 @return flag indicating a mixed language project |
3718 @return flag indicating a mixed language project |
3623 @rtype bool |
3719 @rtype bool |
3624 """ |
3720 """ |
3625 return self.pdata["MIXEDLANGUAGE"] |
3721 return self.__pdata["MIXEDLANGUAGE"] |
3626 |
3722 |
3627 def isPythonProject(self): |
3723 def isPythonProject(self): |
3628 """ |
3724 """ |
3629 Public method to check, if this project is a Python3 or MicroPython |
3725 Public method to check, if this project is a Python3 or MicroPython |
3630 project. |
3726 project. |
3631 |
3727 |
3632 @return flag indicating a Python project (boolean) |
3728 @return flag indicating a Python project (boolean) |
3633 """ |
3729 """ |
3634 return self.pdata["PROGLANGUAGE"] in ["Python3", "MicroPython"] |
3730 return self.__pdata["PROGLANGUAGE"] in ["Python3", "MicroPython"] |
3635 |
3731 |
3636 def isPy3Project(self): |
3732 def isPy3Project(self): |
3637 """ |
3733 """ |
3638 Public method to check, if this project is a Python3 project. |
3734 Public method to check, if this project is a Python3 project. |
3639 |
3735 |
3640 @return flag indicating a Python3 project (boolean) |
3736 @return flag indicating a Python3 project (boolean) |
3641 """ |
3737 """ |
3642 return self.pdata["PROGLANGUAGE"] == "Python3" |
3738 return self.__pdata["PROGLANGUAGE"] == "Python3" |
3643 |
3739 |
3644 def isMicroPythonProject(self): |
3740 def isMicroPythonProject(self): |
3645 """ |
3741 """ |
3646 Public method to check, if this project is a MicroPython project. |
3742 Public method to check, if this project is a MicroPython project. |
3647 |
3743 |
3648 @return flag indicating a MicroPython project |
3744 @return flag indicating a MicroPython project |
3649 @rtype bool |
3745 @rtype bool |
3650 """ |
3746 """ |
3651 return self.pdata["PROGLANGUAGE"] == "MicroPython" |
3747 return self.__pdata["PROGLANGUAGE"] == "MicroPython" |
3652 |
3748 |
3653 def isRubyProject(self): |
3749 def isRubyProject(self): |
3654 """ |
3750 """ |
3655 Public method to check, if this project is a Ruby project. |
3751 Public method to check, if this project is a Ruby project. |
3656 |
3752 |
3657 @return flag indicating a Ruby project (boolean) |
3753 @return flag indicating a Ruby project (boolean) |
3658 """ |
3754 """ |
3659 return self.pdata["PROGLANGUAGE"] == "Ruby" |
3755 return self.__pdata["PROGLANGUAGE"] == "Ruby" |
3660 |
3756 |
3661 def isJavaScriptProject(self): |
3757 def isJavaScriptProject(self): |
3662 """ |
3758 """ |
3663 Public method to check, if this project is a JavaScript project. |
3759 Public method to check, if this project is a JavaScript project. |
3664 |
3760 |
3665 @return flag indicating a JavaScript project (boolean) |
3761 @return flag indicating a JavaScript project (boolean) |
3666 """ |
3762 """ |
3667 return self.pdata["PROGLANGUAGE"] == "JavaScript" |
3763 return self.__pdata["PROGLANGUAGE"] == "JavaScript" |
3668 |
3764 |
3669 def getProjectSpellLanguage(self): |
3765 def getProjectSpellLanguage(self): |
3670 """ |
3766 """ |
3671 Public method to get the project's programming language. |
3767 Public method to get the project's programming language. |
3672 |
3768 |
3673 @return programming language (string) |
3769 @return programming language (string) |
3674 """ |
3770 """ |
3675 return self.pdata["SPELLLANGUAGE"] |
3771 return self.__pdata["SPELLLANGUAGE"] |
3676 |
3772 |
3677 def getProjectDictionaries(self): |
3773 def getProjectDictionaries(self): |
3678 """ |
3774 """ |
3679 Public method to get the names of the project specific dictionaries. |
3775 Public method to get the names of the project specific dictionaries. |
3680 |
3776 |
3681 @return tuple of two strings giving the absolute path names of the |
3777 @return tuple of two strings giving the absolute path names of the |
3682 project specific word and exclude list |
3778 project specific word and exclude list |
3683 """ |
3779 """ |
3684 pwl = "" |
3780 pwl = "" |
3685 if self.pdata["SPELLWORDS"]: |
3781 if self.__pdata["SPELLWORDS"]: |
3686 pwl = os.path.join(self.ppath, self.pdata["SPELLWORDS"]) |
3782 pwl = os.path.join(self.ppath, self.__pdata["SPELLWORDS"]) |
3687 if not os.path.isfile(pwl): |
3783 if not os.path.isfile(pwl): |
3688 pwl = "" |
3784 pwl = "" |
3689 |
3785 |
3690 pel = "" |
3786 pel = "" |
3691 if self.pdata["SPELLEXCLUDES"]: |
3787 if self.__pdata["SPELLEXCLUDES"]: |
3692 pel = os.path.join(self.ppath, self.pdata["SPELLEXCLUDES"]) |
3788 pel = os.path.join(self.ppath, self.__pdata["SPELLEXCLUDES"]) |
3693 if not os.path.isfile(pel): |
3789 if not os.path.isfile(pel): |
3694 pel = "" |
3790 pel = "" |
3695 |
3791 |
3696 return (pwl, pel) |
3792 return (pwl, pel) |
3697 |
3793 |
3853 """ |
3949 """ |
3854 Public method to check, if the project uses the system eol setting. |
3950 Public method to check, if the project uses the system eol setting. |
3855 |
3951 |
3856 @return flag indicating the usage of system eol (boolean) |
3952 @return flag indicating the usage of system eol (boolean) |
3857 """ |
3953 """ |
3858 return self.pdata["EOL"] == 0 |
3954 return self.__pdata["EOL"] == 0 |
3859 |
3955 |
3860 def getProjectVersion(self): |
3956 def getProjectVersion(self): |
3861 """ |
3957 """ |
3862 Public mehod to get the version number of the project. |
3958 Public mehod to get the version number of the project. |
3863 |
3959 |
3864 @return version number |
3960 @return version number |
3865 @rtype str |
3961 @rtype str |
3866 """ |
3962 """ |
3867 return self.pdata["VERSION"] |
3963 return self.__pdata["VERSION"] |
3868 |
3964 |
3869 def getProjectAuthor(self): |
3965 def getProjectAuthor(self): |
3870 """ |
3966 """ |
3871 Public method to get the author of the project. |
3967 Public method to get the author of the project. |
3872 |
3968 |
3873 @return author name |
3969 @return author name |
3874 @rtype str |
3970 @rtype str |
3875 """ |
3971 """ |
3876 return self.pdata["AUTHOR"] |
3972 return self.__pdata["AUTHOR"] |
3877 |
3973 |
3878 def getProjectAuthorEmail(self): |
3974 def getProjectAuthorEmail(self): |
3879 """ |
3975 """ |
3880 Public method to get the email address of the project author. |
3976 Public method to get the email address of the project author. |
3881 |
3977 |
3882 @return project author email |
3978 @return project author email |
3883 @rtype str |
3979 @rtype str |
3884 """ |
3980 """ |
3885 return self.pdata["EMAIL"] |
3981 return self.__pdata["EMAIL"] |
3886 |
3982 |
3887 def getProjectDescription(self): |
3983 def getProjectDescription(self): |
3888 """ |
3984 """ |
3889 Public method to get the description of the project. |
3985 Public method to get the description of the project. |
3890 |
3986 |
3891 @return project description |
3987 @return project description |
3892 @rtype str |
3988 @rtype str |
3893 """ |
3989 """ |
3894 return self.pdata["DESCRIPTION"] |
3990 return self.__pdata["DESCRIPTION"] |
3895 |
3991 |
3896 def getProjectVenv(self, resolveDebugger=True): |
3992 def getProjectVenv(self, resolveDebugger=True): |
3897 """ |
3993 """ |
3898 Public method to get the name of the virtual environment used by the |
3994 Public method to get the name of the virtual environment used by the |
3899 project. |
3995 project. |
4047 @param group group to check (string) |
4145 @param group group to check (string) |
4048 @return flag indicating membership (boolean) |
4146 @return flag indicating membership (boolean) |
4049 """ |
4147 """ |
4050 newfn = os.path.abspath(fn) |
4148 newfn = os.path.abspath(fn) |
4051 newfn = self.getRelativePath(newfn) |
4149 newfn = self.getRelativePath(newfn) |
4052 if newfn in self.pdata[group] or ( |
4150 if newfn in self.__pdata[group] or ( |
4053 group == "OTHERS" |
4151 group == "OTHERS" |
4054 and any(newfn.startswith(entry) for entry in self.pdata[group]) |
4152 and any(newfn.startswith(entry) for entry in self.__pdata[group]) |
4055 ): |
4153 ): |
4056 return True |
4154 return True |
4057 |
4155 |
4058 if Utilities.isWindowsPlatform(): |
4156 if Utilities.isWindowsPlatform(): |
4059 # try the above case-insensitive |
4157 # try the above case-insensitive |
4060 newfn = newfn.lower() |
4158 newfn = newfn.lower() |
4061 if any(entry.lower() == newfn for entry in self.pdata[group]): |
4159 if any(entry.lower() == newfn for entry in self.__pdata[group]): |
4062 return True |
4160 return True |
4063 |
4161 |
4064 elif group == "OTHERS" and any( |
4162 elif group == "OTHERS" and any( |
4065 newfn.startswith(entry.lower()) for entry in self.pdata[group] |
4163 newfn.startswith(entry.lower()) for entry in self.__pdata[group] |
4066 ): |
4164 ): |
4067 return True |
4165 return True |
4068 |
4166 |
4069 return False |
4167 return False |
4070 |
4168 |
|
4169 # TODO: change the following methods to a more generic logix using fileCategories |
4071 def isProjectSource(self, fn): |
4170 def isProjectSource(self, fn): |
4072 """ |
4171 """ |
4073 Public method used to check, if the passed in filename belongs to the |
4172 Public method used to check, if the passed in filename belongs to the |
4074 project sources. |
4173 project sources. |
4075 |
4174 |
5553 dirs.append(d) |
5652 dirs.append(d) |
5554 continue |
5653 continue |
5555 |
5654 |
5556 filetype = "" |
5655 filetype = "" |
5557 bfn = os.path.basename(fn) |
5656 bfn = os.path.basename(fn) |
5558 for pattern in sorted(self.pdata["FILETYPES"].keys(), reverse=True): |
5657 for pattern in sorted(self.__pdata["FILETYPES"].keys(), reverse=True): |
5559 if fnmatch.fnmatch(bfn, pattern): |
5658 if fnmatch.fnmatch(bfn, pattern): |
5560 filetype = self.pdata["FILETYPES"][pattern] |
5659 filetype = self.__pdata["FILETYPES"][pattern] |
5561 break |
5660 break |
5562 |
5661 |
5563 if ( |
5662 if ( |
5564 (filetype == "SOURCES" and fn not in self.pdata["SOURCES"]) |
5663 filetype in self.__knownFileCategories |
5565 or (filetype == "FORMS" and fn not in self.pdata["FORMS"]) |
5664 and fn not in self.__pdata[filetype] |
5566 or (filetype == "INTERFACES" and fn not in self.pdata["INTERFACES"]) |
5665 and ( |
5567 or (filetype == "PROTOCOLS" and fn not in self.pdata["PROTOCOLS"]) |
5666 filetype != "TRANSLATIONS" |
5568 or (filetype == "RESOURCES" and fn not in self.pdata["RESOURCES"]) |
5667 or ( |
5569 or (filetype == "OTHERS" and fn not in self.pdata["OTHERS"]) |
5668 filetype == "TRANSLATIONS" |
5570 or ( |
5669 and ( |
5571 filetype == "TRANSLATIONS" |
5670 fnmatch.fnmatch(ns, pattern) |
5572 and fn not in self.pdata["TRANSLATIONS"] |
5671 or fnmatch.fnmatch(ns, binpattern) |
5573 and ( |
5672 ) |
5574 fnmatch.fnmatch(ns, pattern) |
|
5575 or fnmatch.fnmatch(ns, binpattern) |
|
5576 ) |
5673 ) |
5577 ) |
5674 ) |
5578 ): |
5675 ): |
|
5676 ##(filetype == "SOURCES" and fn not in self.__pdata["SOURCES"]) |
|
5677 ##or (filetype == "FORMS" and fn not in self.__pdata["FORMS"]) |
|
5678 ##or (filetype == "INTERFACES" and fn not in self.__pdata["INTERFACES"]) |
|
5679 ##or (filetype == "PROTOCOLS" and fn not in self.__pdata["PROTOCOLS"]) |
|
5680 ##or (filetype == "RESOURCES" and fn not in self.__pdata["RESOURCES"]) |
|
5681 ##or (filetype == "OTHERS" and fn not in self.__pdata["OTHERS"]) |
|
5682 ##or ( |
|
5683 ##filetype == "TRANSLATIONS" |
|
5684 ##and fn not in self.__pdata["TRANSLATIONS"] |
|
5685 ##and ( |
|
5686 ##fnmatch.fnmatch(ns, pattern) |
|
5687 ##or fnmatch.fnmatch(ns, binpattern) |
|
5688 ##) |
|
5689 ##) |
|
5690 ##): |
5579 if autoInclude and AI: |
5691 if autoInclude and AI: |
5580 self.appendFile(ns) |
5692 self.appendFile(ns) |
5581 else: |
5693 else: |
5582 newFiles.append(ns) |
5694 newFiles.append(ns) |
5583 |
5695 |
5747 "<p>{1}</p>" |
5859 "<p>{1}</p>" |
5748 ).format(vcsSystem, msg), |
5860 ).format(vcsSystem, msg), |
5749 ) |
5861 ) |
5750 vcs = None |
5862 vcs = None |
5751 if forProject: |
5863 if forProject: |
5752 self.pdata["VCS"] = "None" |
5864 self.__pdata["VCS"] = "None" |
5753 self.setDirty(True) |
5865 self.setDirty(True) |
5754 else: |
5866 else: |
5755 vcs.vcsInitConfig(self) |
5867 vcs.vcsInitConfig(self) |
5756 |
5868 |
5757 if vcs and forProject: |
5869 if vcs and forProject: |
5758 # set the vcs options |
5870 # set the vcs options |
5759 if vcs.vcsSupportCommandOptions(): |
5871 if vcs.vcsSupportCommandOptions(): |
5760 with contextlib.suppress(LookupError): |
5872 with contextlib.suppress(LookupError): |
5761 vcsopt = copy.deepcopy(self.pdata["VCSOPTIONS"]) |
5873 vcsopt = copy.deepcopy(self.__pdata["VCSOPTIONS"]) |
5762 vcs.vcsSetOptions(vcsopt) |
5874 vcs.vcsSetOptions(vcsopt) |
5763 # set vcs specific data |
5875 # set vcs specific data |
5764 with contextlib.suppress(LookupError): |
5876 with contextlib.suppress(LookupError): |
5765 vcsother = copy.deepcopy(self.pdata["VCSOTHERDATA"]) |
5877 vcsother = copy.deepcopy(self.__pdata["VCSOTHERDATA"]) |
5766 vcs.vcsSetOtherData(vcsother) |
5878 vcs.vcsSetOtherData(vcsother) |
5767 |
5879 |
5768 if forProject: |
5880 if forProject: |
5769 if vcs is None: |
5881 if vcs is None: |
5770 self.vcsProjectHelper = VCS.getBasicHelper(self) |
5882 self.vcsProjectHelper = VCS.getBasicHelper(self) |
6344 |
6457 |
6345 for name in names: |
6458 for name in names: |
6346 if name: |
6459 if name: |
6347 try: |
6460 try: |
6348 self.__createZipDirEntries(os.path.split(name)[0], archiveFile) |
6461 self.__createZipDirEntries(os.path.split(name)[0], archiveFile) |
6349 if snapshot and name == self.pdata["MAINSCRIPT"]: |
6462 if snapshot and name == self.__pdata["MAINSCRIPT"]: |
6350 snapshotSource, version = self.__createSnapshotSource( |
6463 snapshotSource, version = self.__createSnapshotSource( |
6351 os.path.join(self.ppath, self.pdata["MAINSCRIPT"]) |
6464 os.path.join(self.ppath, self.__pdata["MAINSCRIPT"]) |
6352 ) |
6465 ) |
6353 archiveFile.writestr(name, snapshotSource) |
6466 archiveFile.writestr(name, snapshotSource) |
6354 else: |
6467 else: |
6355 archiveFile.write(os.path.join(self.ppath, name), name) |
6468 archiveFile.write(os.path.join(self.ppath, name), name) |
6356 if name == self.pdata["MAINSCRIPT"]: |
6469 if name == self.__pdata["MAINSCRIPT"]: |
6357 version = self.__pluginExtractVersion( |
6470 version = self.__pluginExtractVersion( |
6358 os.path.join(self.ppath, self.pdata["MAINSCRIPT"]) |
6471 os.path.join(self.ppath, self.__pdata["MAINSCRIPT"]) |
6359 ) |
6472 ) |
6360 if archiveVersion and ( |
6473 if archiveVersion and ( |
6361 self.__pluginVersionToTuple(version) |
6474 self.__pluginVersionToTuple(version) |
6362 < self.__pluginVersionToTuple(archiveVersion) |
6475 < self.__pluginVersionToTuple(archiveVersion) |
6363 ): |
6476 ): |
6558 @param interactive flag indicating an interactive invocation (i.e. |
6671 @param interactive flag indicating an interactive invocation (i.e. |
6559 through a menu action) |
6672 through a menu action) |
6560 @type bool |
6673 @type bool |
6561 """ |
6674 """ |
6562 if ( |
6675 if ( |
6563 not self.pdata["MAKEPARAMS"]["MakeEnabled"] |
6676 not self.__pdata["MAKEPARAMS"]["MakeEnabled"] |
6564 or self.__makeProcess is not None |
6677 or self.__makeProcess is not None |
6565 ): |
6678 ): |
6566 return |
6679 return |
6567 |
6680 |
6568 prog = ( |
6681 prog = ( |
6569 self.pdata["MAKEPARAMS"]["MakeExecutable"] |
6682 self.__pdata["MAKEPARAMS"]["MakeExecutable"] |
6570 if self.pdata["MAKEPARAMS"]["MakeExecutable"] |
6683 if self.__pdata["MAKEPARAMS"]["MakeExecutable"] |
6571 else Project.DefaultMake |
6684 else Project.DefaultMake |
6572 ) |
6685 ) |
6573 |
6686 |
6574 args = [] |
6687 args = [] |
6575 if self.pdata["MAKEPARAMS"]["MakeParameters"]: |
6688 if self.__pdata["MAKEPARAMS"]["MakeParameters"]: |
6576 args.extend( |
6689 args.extend( |
6577 Utilities.parseOptionString(self.pdata["MAKEPARAMS"]["MakeParameters"]) |
6690 Utilities.parseOptionString( |
6578 ) |
6691 self.__pdata["MAKEPARAMS"]["MakeParameters"] |
6579 |
6692 ) |
6580 if self.pdata["MAKEPARAMS"]["MakeFile"]: |
6693 ) |
6581 args.append("--makefile={0}".format(self.pdata["MAKEPARAMS"]["MakeFile"])) |
6694 |
|
6695 if self.__pdata["MAKEPARAMS"]["MakeFile"]: |
|
6696 args.append("--makefile={0}".format(self.__pdata["MAKEPARAMS"]["MakeFile"])) |
6582 |
6697 |
6583 if questionOnly: |
6698 if questionOnly: |
6584 args.append("--question") |
6699 args.append("--question") |
6585 |
6700 |
6586 if self.pdata["MAKEPARAMS"]["MakeTarget"]: |
6701 if self.__pdata["MAKEPARAMS"]["MakeTarget"]: |
6587 args.append(self.pdata["MAKEPARAMS"]["MakeTarget"]) |
6702 args.append(self.__pdata["MAKEPARAMS"]["MakeTarget"]) |
6588 |
6703 |
6589 self.__makeProcess = QProcess(self) |
6704 self.__makeProcess = QProcess(self) |
6590 self.__makeProcess.readyReadStandardOutput.connect(self.__makeReadStdOut) |
6705 self.__makeProcess.readyReadStandardOutput.connect(self.__makeReadStdOut) |
6591 self.__makeProcess.readyReadStandardError.connect(self.__makeReadStdErr) |
6706 self.__makeProcess.readyReadStandardError.connect(self.__makeReadStdErr) |
6592 self.__makeProcess.finished.connect( |
6707 self.__makeProcess.finished.connect( |