src/eric7/Project/Project.py

branch
eric7-maintenance
changeset 10460
3b34efa2857c
parent 10364
e90957951622
parent 10456
12c30c88ed05
child 10534
783d835d7fe4
equal deleted inserted replaced
10366:411df92e881f 10460:3b34efa2857c
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 2
3 # Copyright (c) 2002 - 2023 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2002 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the project management functionality. 7 Module implementing the project management functionality.
8 """ 8 """
166 166
167 def __init__(self, parent=None, filename=None): 167 def __init__(self, parent=None, filename=None):
168 """ 168 """
169 Constructor 169 Constructor
170 170
171 @param parent parent widget (usually the ui object) (QWidget) 171 @param parent parent widget (usually the ui object)
172 @param filename optional filename of a project file to open (string) 172 @type QWidget
173 @param filename optional filename of a project file to open
174 @type str
173 """ 175 """
174 super().__init__(parent) 176 super().__init__(parent)
175 177
176 self.ui = parent 178 self.ui = parent
177 179
272 274
273 def __sourceExtensions(self, language): 275 def __sourceExtensions(self, language):
274 """ 276 """
275 Private method to get the source extensions of a programming language. 277 Private method to get the source extensions of a programming language.
276 278
277 @param language programming language (string) 279 @param language programming language
278 @return source extensions (list of string) 280 @type str
281 @return source extensions
282 @rtype list of str
279 """ 283 """
280 if language == "Python3": 284 if language == "Python3":
281 extensions = Preferences.getPython("Python3Extensions") 285 extensions = Preferences.getPython("Python3Extensions")
282 # *.py and *.pyw should always be associated with source files 286 # *.py and *.pyw should always be associated with source files
283 for ext in [".py", ".pyw"]: 287 for ext in [".py", ".pyw"]:
300 304
301 def getProgrammingLanguages(self): 305 def getProgrammingLanguages(self):
302 """ 306 """
303 Public method to get the programming languages supported by project. 307 Public method to get the programming languages supported by project.
304 308
305 @return list of supported programming languages (list of string) 309 @return list of supported programming languages
310 @rtype list of str
306 """ 311 """
307 return self.__progLanguages[:] 312 return self.__progLanguages[:]
308 313
309 def getDebuggerFilters(self, language): 314 def getDebuggerFilters(self, language):
310 """ 315 """
366 def getProjectTypes(self, progLanguage=""): 371 def getProjectTypes(self, progLanguage=""):
367 """ 372 """
368 Public method to get the list of supported project types. 373 Public method to get the list of supported project types.
369 374
370 @param progLanguage programming language to get project types for 375 @param progLanguage programming language to get project types for
371 (string) 376 @type str
372 @return reference to the dictionary of project types. 377 @return reference to the dictionary of project types.
378 @rtype dict
373 """ 379 """
374 if progLanguage and progLanguage in self.__projectProgLanguages: 380 if progLanguage and progLanguage in self.__projectProgLanguages:
375 ptypes = {} 381 ptypes = {}
376 for ptype in self.__projectProgLanguages[progLanguage]: 382 for ptype in self.__projectProgLanguages[progLanguage]:
377 ptypes[ptype] = self.__projectTypes[ptype] 383 ptypes[ptype] = self.__projectTypes[ptype]
381 387
382 def hasProjectType(self, type_, progLanguage=""): 388 def hasProjectType(self, type_, progLanguage=""):
383 """ 389 """
384 Public method to check, if a project type is already registered. 390 Public method to check, if a project type is already registered.
385 391
386 @param type_ internal type designator (string) 392 @param type_ internal type designator
387 @param progLanguage programming language of the project type (string) 393 @type str
388 @return flag indicating presence of the project type (boolean) 394 @param progLanguage programming language of the project type
395 @type str
396 @return flag indicating presence of the project type
397 @rtype bool
389 """ 398 """
390 if progLanguage: 399 if progLanguage:
391 return ( 400 return (
392 progLanguage in self.__projectProgLanguages 401 progLanguage in self.__projectProgLanguages
393 and type_ in self.__projectProgLanguages[progLanguage] 402 and type_ in self.__projectProgLanguages[progLanguage]
405 progLanguages=None, 414 progLanguages=None,
406 ): 415 ):
407 """ 416 """
408 Public method to register a project type. 417 Public method to register a project type.
409 418
410 @param type_ internal type designator to be registered (string) 419 @param type_ internal type designator to be registered
411 @param description more verbose type name (display string) (string) 420 @type str
421 @param description more verbose type name (display string)
422 @type str
412 @param fileTypeCallback reference to a method returning a dictionary 423 @param fileTypeCallback reference to a method returning a dictionary
413 of filetype associations. 424 of filetype associations
425 @type function
414 @param binaryTranslationsCallback reference to a method returning 426 @param binaryTranslationsCallback reference to a method returning
415 the name of the binary translation file given the name of the raw 427 the name of the binary translation file given the name of the raw
416 translation file 428 translation file
429 @type function
417 @param lexerAssociationCallback reference to a method returning the 430 @param lexerAssociationCallback reference to a method returning the
418 lexer type to be used for syntax highlighting given the name of 431 lexer type to be used for syntax highlighting given the name of
419 a file 432 a file
433 @type function
420 @param progLanguages programming languages supported by the 434 @param progLanguages programming languages supported by the
421 project type (list of string) 435 project type
436 @type list of str
422 """ 437 """
423 if progLanguages: 438 if progLanguages:
424 for progLanguage in progLanguages: 439 for progLanguage in progLanguages:
425 if progLanguage not in self.__projectProgLanguages: 440 if progLanguage not in self.__projectProgLanguages:
426 EricMessageBox.critical( 441 EricMessageBox.critical(
469 484
470 def unregisterProjectType(self, type_): 485 def unregisterProjectType(self, type_):
471 """ 486 """
472 Public method to unregister a project type. 487 Public method to unregister a project type.
473 488
474 @param type_ internal type designator to be unregistered (string) 489 @param type_ internal type designator to be unregistered
490 @type str
475 """ 491 """
476 for progLanguage in self.__projectProgLanguages: 492 for progLanguage in self.__projectProgLanguages:
477 if type_ in self.__projectProgLanguages[progLanguage]: 493 if type_ in self.__projectProgLanguages[progLanguage]:
478 self.__projectProgLanguages[progLanguage].remove(type_) 494 self.__projectProgLanguages[progLanguage].remove(type_)
479 if type_ in self.__projectTypes: 495 if type_ in self.__projectTypes:
644 @param key key of the data entry to get 660 @param key key of the data entry to get
645 @type str 661 @type str
646 @param default value to return in case the key is not found (defaults to None) 662 @param default value to return in case the key is not found (defaults to None)
647 @type Any (optional) 663 @type Any (optional)
648 @return a copy of the requested data or None 664 @return a copy of the requested data or None
665 @rtype Any
649 """ 666 """
650 # __IGNORE_WARNING_D202__ 667 # __IGNORE_WARNING_D202__
651 if ( 668 if (
652 category 669 category
653 in [ 670 in [
665 682
666 def setData(self, category, key, data): 683 def setData(self, category, key, data):
667 """ 684 """
668 Public method to store data in the project data store. 685 Public method to store data in the project data store.
669 686
670 @param category category of the data to get (string, one of 687 @param category category of the data to get (one of
671 PROJECTTYPESPECIFICDATA, CHECKERSPARMS, PACKAGERSPARMS, 688 PROJECTTYPESPECIFICDATA, CHECKERSPARMS, PACKAGERSPARMS,
672 DOCUMENTATIONPARMS or OTHERTOOLSPARMS) 689 DOCUMENTATIONPARMS or OTHERTOOLSPARMS)
673 @param key key of the data entry to get (string). 690 @type str
691 @param key key of the data entry to get
692 @type str
674 @param data data to be stored 693 @param data data to be stored
675 @return flag indicating success (boolean) 694 @type Any
695 @return flag indicating success
696 @rtype bool
676 """ 697 """
677 # __IGNORE_WARNING_D202__ 698 # __IGNORE_WARNING_D202__
678 if category not in [ 699 if category not in [
679 "PROJECTTYPESPECIFICDATA", 700 "PROJECTTYPESPECIFICDATA",
680 "CHECKERSPARMS", 701 "CHECKERSPARMS",
708 Public method to get the list of known file categories. 729 Public method to get the list of known file categories.
709 730
710 @return list of known file categories 731 @return list of known file categories
711 @rtype list of str 732 @rtype list of str
712 """ 733 """
713 return list(self.__fileCategoriesRepository.keys()) 734 return list(self.__fileCategoriesRepository)
714 735
715 def getFileCategoryFilters(self, categories=None, withOthers=False, withAll=True): 736 def getFileCategoryFilters(self, categories=None, withOthers=False, withAll=True):
716 """ 737 """
717 Public method to get a list of file selection filters for the given categories. 738 Public method to get a list of file selection filters for the given categories.
718 739
908 fileTypesDict["*.qm"] = "TRANSLATIONS" 929 fileTypesDict["*.qm"] = "TRANSLATIONS"
909 930
910 # File categories handled by activated plugin project browsers 931 # File categories handled by activated plugin project browsers
911 for fileCategory in [ 932 for fileCategory in [
912 f 933 f
913 for f in self.__fileCategoriesRepository.keys() 934 for f in self.__fileCategoriesRepository
914 if f not in ["SOURCES", "FORMS", "RESOURCES", "TRANSLATIONS", "OTHERS"] 935 if f not in ["SOURCES", "FORMS", "RESOURCES", "TRANSLATIONS", "OTHERS"]
915 ]: 936 ]:
916 for ext in self.__fileCategoriesRepository[ 937 for ext in self.__fileCategoriesRepository[
917 fileCategory.upper() 938 fileCategory.upper()
918 ].fileCategoryExtensions: 939 ].fileCategoryExtensions:
946 if "*.qm" not in self.__pdata["FILETYPES"]: 967 if "*.qm" not in self.__pdata["FILETYPES"]:
947 self.__pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" 968 self.__pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS"
948 with contextlib.suppress(KeyError): 969 with contextlib.suppress(KeyError):
949 if self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]] is not None: 970 if self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]] is not None:
950 ftypes = self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]]() 971 ftypes = self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]]()
951 for pattern, ftype in list(ftypes.items()): 972 for pattern, ftype in ftypes.items():
952 if pattern not in self.__pdata["FILETYPES"]: 973 if pattern not in self.__pdata["FILETYPES"]:
953 self.__pdata["FILETYPES"][pattern] = ftype 974 self.__pdata["FILETYPES"][pattern] = ftype
954 self.setDirty(True) 975 self.setDirty(True)
955 976
956 def __loadRecent(self): 977 def __loadRecent(self):
974 995
975 def getMostRecent(self): 996 def getMostRecent(self):
976 """ 997 """
977 Public method to get the most recently opened project. 998 Public method to get the most recently opened project.
978 999
979 @return path of the most recently opened project (string) 1000 @return path of the most recently opened project
1001 @rtype str
980 """ 1002 """
981 if len(self.recent): 1003 if len(self.recent):
982 return self.recent[0] 1004 return self.recent[0]
983 else: 1005 else:
984 return None 1006 return None
985 1007
986 def getModel(self): 1008 def getModel(self):
987 """ 1009 """
988 Public method to get a reference to the project browser model. 1010 Public method to get a reference to the project browser model.
989 1011
990 @return reference to the project browser model (ProjectBrowserModel) 1012 @return reference to the project browser model
1013 @rtype ProjectBrowserModel
991 """ 1014 """
992 return self.__model 1015 return self.__model
993 1016
994 def startFileSystemMonitoring(self): 1017 def startFileSystemMonitoring(self):
995 """ 1018 """
1006 def getVcs(self): 1029 def getVcs(self):
1007 """ 1030 """
1008 Public method to get a reference to the VCS object. 1031 Public method to get a reference to the VCS object.
1009 1032
1010 @return reference to the VCS object 1033 @return reference to the VCS object
1034 @rtype VersionControl
1011 """ 1035 """
1012 return self.vcs 1036 return self.vcs
1013 1037
1014 def isVcsControlled(self): 1038 def isVcsControlled(self):
1015 """ 1039 """
1052 1076
1053 def isDirty(self): 1077 def isDirty(self):
1054 """ 1078 """
1055 Public method to return the dirty state. 1079 Public method to return the dirty state.
1056 1080
1057 @return dirty state (boolean) 1081 @return dirty state
1082 @rtype bool
1058 """ 1083 """
1059 return self.__dirty 1084 return self.__dirty
1060 1085
1061 def isOpen(self): 1086 def isOpen(self):
1062 """ 1087 """
1063 Public method to return the opened state. 1088 Public method to return the opened state.
1064 1089
1065 @return open state (boolean) 1090 @return open state
1091 @rtype bool
1066 """ 1092 """
1067 return self.opened 1093 return self.opened
1068 1094
1069 def __checkFilesExist(self, index): 1095 def __checkFilesExist(self, index):
1070 """ 1096 """
1072 1098
1073 The files in the indicated list are checked for existance in the 1099 The files in the indicated list are checked for existance in the
1074 filesystem. Non existant files are removed from the list and the 1100 filesystem. Non existant files are removed from the list and the
1075 dirty state of the project is changed accordingly. 1101 dirty state of the project is changed accordingly.
1076 1102
1077 @param index key of the list to be checked (string) 1103 @param index key of the list to be checked
1104 @type str
1078 """ 1105 """
1079 removed = False 1106 removed = False
1080 removelist = [] 1107 removelist = []
1081 for file in self.__pdata[index]: 1108 for file in self.__pdata[index]:
1082 if not os.path.exists(os.path.join(self.ppath, file)): 1109 if not os.path.exists(os.path.join(self.ppath, file)):
1090 1117
1091 def __readProject(self, fn): 1118 def __readProject(self, fn):
1092 """ 1119 """
1093 Private method to read in a project (.epj or .e4p) file. 1120 Private method to read in a project (.epj or .e4p) file.
1094 1121
1095 @param fn filename of the project file to be read (string) 1122 @param fn filename of the project file to be read
1123 @type str
1096 @return flag indicating success 1124 @return flag indicating success
1125 @rtype bool
1097 """ 1126 """
1098 if os.path.splitext(fn)[1] == ".epj": 1127 if os.path.splitext(fn)[1] == ".epj":
1099 # new JSON based format 1128 # new JSON based format
1100 with EricOverrideCursor(): 1129 with EricOverrideCursor():
1101 res = self.__projectFile.readFile(fn) 1130 res = self.__projectFile.readFile(fn)
1178 @param fn optional filename of the project file to be written (string). 1207 @param fn optional filename of the project file to be written (string).
1179 If fn is None, the filename stored in the project object 1208 If fn is None, the filename stored in the project object
1180 is used. This is the 'save' action. If fn is given, this filename 1209 is used. This is the 'save' action. If fn is given, this filename
1181 is used instead of the one in the project object. This is the 1210 is used instead of the one in the project object. This is the
1182 'save as' action. 1211 'save as' action.
1212 @type str
1183 @return flag indicating success 1213 @return flag indicating success
1214 @rtype bool
1184 """ 1215 """
1185 if self.vcs is not None: 1216 if self.vcs is not None:
1186 self.__pdata["VCSOPTIONS"] = copy.deepcopy(self.vcs.vcsGetOptions()) 1217 self.__pdata["VCSOPTIONS"] = copy.deepcopy(self.vcs.vcsGetOptions())
1187 self.__pdata["VCSOTHERDATA"] = copy.deepcopy(self.vcs.vcsGetOtherData()) 1218 self.__pdata["VCSOTHERDATA"] = copy.deepcopy(self.vcs.vcsGetOtherData())
1188 1219
1278 """ 1309 """
1279 Private method to read in the project session file (.esj or .e5s). 1310 Private method to read in the project session file (.esj or .e5s).
1280 1311
1281 @param quiet flag indicating quiet operations. 1312 @param quiet flag indicating quiet operations.
1282 If this flag is true, no errors are reported. 1313 If this flag is true, no errors are reported.
1283 @param indicator indicator string (string) 1314 @type bool
1315 @param indicator indicator string
1316 @type str
1284 """ 1317 """
1285 if self.pfile is None: 1318 if self.pfile is None:
1286 if not quiet: 1319 if not quiet:
1287 EricMessageBox.critical( 1320 EricMessageBox.critical(
1288 self.ui, 1321 self.ui,
1325 """ 1358 """
1326 Private method to write the session data to an XML file (.esj). 1359 Private method to write the session data to an XML file (.esj).
1327 1360
1328 @param quiet flag indicating quiet operations. 1361 @param quiet flag indicating quiet operations.
1329 If this flag is true, no errors are reported. 1362 If this flag is true, no errors are reported.
1330 @param indicator indicator string (string) 1363 @type bool
1364 @param indicator indicator string
1365 @type str
1331 """ 1366 """
1332 if self.pfile is None: 1367 if self.pfile is None:
1333 if not quiet: 1368 if not quiet:
1334 EricMessageBox.critical( 1369 EricMessageBox.critical(
1335 self.ui, 1370 self.ui,
1451 Private method to read in the project debugger properties file 1486 Private method to read in the project debugger properties file
1452 (.edj or .e4d). 1487 (.edj or .e4d).
1453 1488
1454 @param quiet flag indicating quiet operations. 1489 @param quiet flag indicating quiet operations.
1455 If this flag is true, no errors are reported. 1490 If this flag is true, no errors are reported.
1491 @type bool
1456 """ 1492 """
1457 if self.pfile is None: 1493 if self.pfile is None:
1458 if not quiet: 1494 if not quiet:
1459 EricMessageBox.critical( 1495 EricMessageBox.critical(
1460 self.ui, 1496 self.ui,
1497 """ 1533 """
1498 Private method to write the project debugger properties file (.edj). 1534 Private method to write the project debugger properties file (.edj).
1499 1535
1500 @param quiet flag indicating quiet operations. 1536 @param quiet flag indicating quiet operations.
1501 If this flag is true, no errors are reported. 1537 If this flag is true, no errors are reported.
1538 @type bool
1502 """ 1539 """
1503 if self.pfile is None: 1540 if self.pfile is None:
1504 if not quiet: 1541 if not quiet:
1505 EricMessageBox.critical( 1542 EricMessageBox.critical(
1506 self.ui, 1543 self.ui,
1573 1610
1574 def isDebugPropertiesLoaded(self): 1611 def isDebugPropertiesLoaded(self):
1575 """ 1612 """
1576 Public method to return the status of the debug properties. 1613 Public method to return the status of the debug properties.
1577 1614
1578 @return load status of debug properties (boolean) 1615 @return load status of debug properties
1616 @rtype bool
1579 """ 1617 """
1580 return self.debugPropertiesLoaded or self.__pdata["EMBEDDED_VENV"] 1618 return self.debugPropertiesLoaded or self.__pdata["EMBEDDED_VENV"]
1581 1619
1582 def __showDebugProperties(self): 1620 def __showDebugProperties(self):
1583 """ 1621 """
1591 1629
1592 def getDebugProperty(self, key): 1630 def getDebugProperty(self, key):
1593 """ 1631 """
1594 Public method to retrieve a debugger property. 1632 Public method to retrieve a debugger property.
1595 1633
1596 @param key key of the property (string) 1634 @param key key of the property
1635 @type str
1597 @return value of the property 1636 @return value of the property
1637 @rtype Any
1598 """ 1638 """
1599 if key == "INTERPRETER": 1639 if key == "INTERPRETER":
1600 return ( 1640 return (
1601 ericApp() 1641 ericApp()
1602 .getObject("VirtualEnvManager") 1642 .getObject("VirtualEnvManager")
1680 1720
1681 def getTranslationPattern(self): 1721 def getTranslationPattern(self):
1682 """ 1722 """
1683 Public method to get the translation pattern. 1723 Public method to get the translation pattern.
1684 1724
1685 @return translation pattern (string) 1725 @return translation pattern
1726 @rtype str
1686 """ 1727 """
1687 return self.__pdata["TRANSLATIONPATTERN"] 1728 return self.__pdata["TRANSLATIONPATTERN"]
1688 1729
1689 def setTranslationPattern(self, pattern): 1730 def setTranslationPattern(self, pattern):
1690 """ 1731 """
1732 def __binaryTranslationFile(self, langFile): 1773 def __binaryTranslationFile(self, langFile):
1733 """ 1774 """
1734 Private method to calculate the filename of the binary translations 1775 Private method to calculate the filename of the binary translations
1735 file given the name of the raw translations file. 1776 file given the name of the raw translations file.
1736 1777
1737 @param langFile name of the raw translations file (string) 1778 @param langFile name of the raw translations file
1738 @return name of the binary translations file (string) 1779 @type str
1780 @return name of the binary translations file
1781 @rtype str
1739 """ 1782 """
1740 qmFile = "" 1783 qmFile = ""
1741 try: 1784 try:
1742 if ( 1785 if (
1743 self.__binaryTranslationsCallbacks[self.__pdata["PROJECTTYPE"]] 1786 self.__binaryTranslationsCallbacks[self.__pdata["PROJECTTYPE"]]
1775 """ 1818 """
1776 Public slot to remove a translation from the project. 1819 Public slot to remove a translation from the project.
1777 1820
1778 The translation file is not deleted from the project directory. 1821 The translation file is not deleted from the project directory.
1779 1822
1780 @param langFile the translation file to be removed (string) 1823 @param langFile the translation file to be removed
1824 @type str
1781 """ 1825 """
1782 langFile = self.getRelativePath(langFile) 1826 langFile = self.getRelativePath(langFile)
1783 qmFile = self.__binaryTranslationFile(langFile) 1827 qmFile = self.__binaryTranslationFile(langFile)
1784 with contextlib.suppress(ValueError): 1828 with contextlib.suppress(ValueError):
1785 self.__model.removeItem(langFile) 1829 self.__model.removeItem(langFile)
1799 1843
1800 def deleteLanguageFile(self, langFile): 1844 def deleteLanguageFile(self, langFile):
1801 """ 1845 """
1802 Public slot to delete a translation from the project directory. 1846 Public slot to delete a translation from the project directory.
1803 1847
1804 @param langFile the translation file to be removed (string) 1848 @param langFile the translation file to be removed
1849 @type str
1805 """ 1850 """
1806 langFile = self.getRelativePath(langFile) 1851 langFile = self.getRelativePath(langFile)
1807 qmFile = self.__binaryTranslationFile(langFile) 1852 qmFile = self.__binaryTranslationFile(langFile)
1808 1853
1809 try: 1854 try:
1849 1894
1850 def appendFile(self, fn, isSourceFile=False, updateModel=True): 1895 def appendFile(self, fn, isSourceFile=False, updateModel=True):
1851 """ 1896 """
1852 Public method to append a file to the project. 1897 Public method to append a file to the project.
1853 1898
1854 @param fn filename to be added to the project (string) 1899 @param fn filename to be added to the project
1900 @type str
1855 @param isSourceFile flag indicating that this is a source file 1901 @param isSourceFile flag indicating that this is a source file
1856 even if it doesn't have the source extension (boolean) 1902 even if it doesn't have the source extension
1903 @type bool
1857 @param updateModel flag indicating an update of the model is 1904 @param updateModel flag indicating an update of the model is
1858 requested (boolean) 1905 requested
1906 @type bool
1859 """ 1907 """
1860 dirty = False 1908 dirty = False
1861 1909
1862 # make it relative to the project root, if it starts with that path 1910 # make it relative to the project root, if it starts with that path
1863 # assume relative paths are relative to the project root 1911 # assume relative paths are relative to the project root
1870 filetype = "OTHERS" 1918 filetype = "OTHERS"
1871 bfn = os.path.basename(newfn) 1919 bfn = os.path.basename(newfn)
1872 if fnmatch.fnmatch(bfn, "*.ts") or fnmatch.fnmatch(bfn, "*.qm"): 1920 if fnmatch.fnmatch(bfn, "*.ts") or fnmatch.fnmatch(bfn, "*.qm"):
1873 filetype = "TRANSLATIONS" 1921 filetype = "TRANSLATIONS"
1874 else: 1922 else:
1875 for pattern in sorted(self.__pdata["FILETYPES"].keys(), reverse=True): 1923 for pattern in sorted(self.__pdata["FILETYPES"], reverse=True):
1876 if fnmatch.fnmatch(bfn, pattern): 1924 if fnmatch.fnmatch(bfn, pattern):
1877 filetype = self.__pdata["FILETYPES"][pattern] 1925 filetype = self.__pdata["FILETYPES"][pattern]
1878 break 1926 break
1879 1927
1880 if filetype == "__IGNORE__": 1928 if filetype == "__IGNORE__":
1978 def __addSingleDirectory(self, filetype, source, target, quiet=False): 2026 def __addSingleDirectory(self, filetype, source, target, quiet=False):
1979 """ 2027 """
1980 Private method used to add all files of a single directory to the 2028 Private method used to add all files of a single directory to the
1981 project. 2029 project.
1982 2030
1983 @param filetype type of files to add (string) 2031 @param filetype type of files to add
1984 @param source source directory (string) 2032 @type str
1985 @param target target directory (string) 2033 @param source source directory
1986 @param quiet flag indicating quiet operations (boolean) 2034 @type str
2035 @param target target directory
2036 @type str
2037 @param quiet flag indicating quiet operations
2038 @type bool
1987 """ 2039 """
1988 # get all relevant filename patterns 2040 # get all relevant filename patterns
1989 patterns = [] 2041 patterns = []
1990 ignorePatterns = [] 2042 ignorePatterns = []
1991 for pattern, patterntype in list(self.__pdata["FILETYPES"].items()): 2043 for pattern, patterntype in self.__pdata["FILETYPES"].items():
1992 if patterntype == filetype: 2044 if patterntype == filetype:
1993 patterns.append(pattern) 2045 patterns.append(pattern)
1994 elif patterntype == "__IGNORE__": 2046 elif patterntype == "__IGNORE__":
1995 ignorePatterns.append(pattern) 2047 ignorePatterns.append(pattern)
1996 2048
2059 Private method used to add all files of a directory tree. 2111 Private method used to add all files of a directory tree.
2060 2112
2061 The tree is rooted at source to another one rooted at target. This 2113 The tree is rooted at source to another one rooted at target. This
2062 method decents down to the lowest subdirectory. 2114 method decents down to the lowest subdirectory.
2063 2115
2064 @param filetype type of files to add (string) 2116 @param filetype type of files to add
2065 @param source source directory (string) 2117 @type str
2066 @param target target directory (string) 2118 @param source source directory
2119 @type str
2120 @param target target directory
2121 @type str
2067 """ 2122 """
2068 # first perform the addition of source 2123 # first perform the addition of source
2069 self.__addSingleDirectory(filetype, source, target, True) 2124 self.__addSingleDirectory(filetype, source, target, True)
2070 2125
2071 ignore_patterns = [ 2126 ignore_patterns = [
2138 2193
2139 def addToOthers(self, fn): 2194 def addToOthers(self, fn):
2140 """ 2195 """
2141 Public method to add a file/directory to the OTHERS project data. 2196 Public method to add a file/directory to the OTHERS project data.
2142 2197
2143 @param fn file name or directory name to add (string) 2198 @param fn file name or directory name to add
2199 @type str
2144 """ 2200 """
2145 if fn: 2201 if fn:
2146 # if it is below the project directory, make it relative to that 2202 # if it is below the project directory, make it relative to that
2147 fn = self.getRelativePath(fn) 2203 fn = self.getRelativePath(fn)
2148 2204
2160 2216
2161 def renameMainScript(self, oldfn, newfn): 2217 def renameMainScript(self, oldfn, newfn):
2162 """ 2218 """
2163 Public method to rename the main script. 2219 Public method to rename the main script.
2164 2220
2165 @param oldfn old filename (string) 2221 @param oldfn old filename
2166 @param newfn new filename of the main script (string) 2222 @type str
2223 @param newfn new filename of the main script
2224 @type str
2167 """ 2225 """
2168 if self.__pdata["MAINSCRIPT"]: 2226 if self.__pdata["MAINSCRIPT"]:
2169 ofn = self.getRelativePath(oldfn) 2227 ofn = self.getRelativePath(oldfn)
2170 if ofn != self.__pdata["MAINSCRIPT"]: 2228 if ofn != self.__pdata["MAINSCRIPT"]:
2171 return 2229 return
2176 2234
2177 def renameFile(self, oldfn, newfn=None): 2235 def renameFile(self, oldfn, newfn=None):
2178 """ 2236 """
2179 Public slot to rename a file of the project. 2237 Public slot to rename a file of the project.
2180 2238
2181 @param oldfn old filename of the file (string) 2239 @param oldfn old filename of the file
2182 @param newfn new filename of the file (string) 2240 @type str
2241 @param newfn new filename of the file
2242 @type str
2183 @return flag indicating success 2243 @return flag indicating success
2244 @rtype bool
2184 """ 2245 """
2185 fn = self.getRelativePath(oldfn) 2246 fn = self.getRelativePath(oldfn)
2186 isSourceFile = fn in self.__pdata["SOURCES"] 2247 isSourceFile = fn in self.__pdata["SOURCES"]
2187 2248
2188 if newfn is None: 2249 if newfn is None:
2230 2291
2231 def renameFileInPdata(self, oldname, newname, isSourceFile=False): 2292 def renameFileInPdata(self, oldname, newname, isSourceFile=False):
2232 """ 2293 """
2233 Public method to rename a file in the __pdata structure. 2294 Public method to rename a file in the __pdata structure.
2234 2295
2235 @param oldname old filename (string) 2296 @param oldname old filename
2236 @param newname new filename (string) 2297 @type str
2298 @param newname new filename
2299 @type str
2237 @param isSourceFile flag indicating that this is a source file 2300 @param isSourceFile flag indicating that this is a source file
2238 even if it doesn't have the source extension (boolean) 2301 even if it doesn't have the source extension
2302 @type bool
2239 """ 2303 """
2240 fn = self.getRelativePath(oldname) 2304 fn = self.getRelativePath(oldname)
2241 if os.path.dirname(oldname) == os.path.dirname(newname): 2305 if os.path.dirname(oldname) == os.path.dirname(newname):
2242 if self.__isInPdata(oldname): 2306 if self.__isInPdata(oldname):
2243 self.removeFile(oldname, False) 2307 self.removeFile(oldname, False)
2252 2316
2253 def getFiles(self, start): 2317 def getFiles(self, start):
2254 """ 2318 """
2255 Public method to get all files starting with a common prefix. 2319 Public method to get all files starting with a common prefix.
2256 2320
2257 @param start prefix (string) 2321 @param start prefix
2258 @return list of files starting with a common prefix (list of strings) 2322 @type str
2323 @return list of files starting with a common prefix
2324 @rtype list of str
2259 """ 2325 """
2260 filelist = [] 2326 filelist = []
2261 start = self.getRelativePath(start) 2327 start = self.getRelativePath(start)
2262 for fileCategory in [ 2328 for fileCategory in [
2263 c for c in self.getFileCategories() if c != "TRANSLATIONS" 2329 c for c in self.getFileCategories() if c != "TRANSLATIONS"
2281 # iterate over all files checking for a reassignment 2347 # iterate over all files checking for a reassignment
2282 for fileCategory in self.getFileCategories(): 2348 for fileCategory in self.getFileCategories():
2283 for fn in self.__pdata[fileCategory][:]: 2349 for fn in self.__pdata[fileCategory][:]:
2284 filetype = fileCategory 2350 filetype = fileCategory
2285 bfn = os.path.basename(fn) 2351 bfn = os.path.basename(fn)
2286 for pattern in sorted(self.__pdata["FILETYPES"].keys(), reverse=True): 2352 for pattern in sorted(self.__pdata["FILETYPES"], reverse=True):
2287 if fnmatch.fnmatch(bfn, pattern): 2353 if fnmatch.fnmatch(bfn, pattern):
2288 filetype = self.__pdata["FILETYPES"][pattern] 2354 filetype = self.__pdata["FILETYPES"][pattern]
2289 break 2355 break
2290 2356
2291 if filetype != "__IGNORE__": 2357 if filetype != "__IGNORE__":
2304 2370
2305 def copyDirectory(self, olddn, newdn): 2371 def copyDirectory(self, olddn, newdn):
2306 """ 2372 """
2307 Public slot to copy a directory. 2373 Public slot to copy a directory.
2308 2374
2309 @param olddn original directory name (string) 2375 @param olddn original directory name
2310 @param newdn new directory name (string) 2376 @type str
2377 @param newdn new directory name
2378 @type str
2311 """ 2379 """
2312 olddn = self.getRelativePath(olddn) 2380 olddn = self.getRelativePath(olddn)
2313 newdn = self.getRelativePath(newdn) 2381 newdn = self.getRelativePath(newdn)
2314 for fileCategory in [ 2382 for fileCategory in [
2315 c for c in self.getFileCategories() if c != "TRANSLATIONS" 2383 c for c in self.getFileCategories() if c != "TRANSLATIONS"
2324 2392
2325 def moveDirectory(self, olddn, newdn): 2393 def moveDirectory(self, olddn, newdn):
2326 """ 2394 """
2327 Public slot to move a directory. 2395 Public slot to move a directory.
2328 2396
2329 @param olddn old directory name (string) 2397 @param olddn old directory name
2330 @param newdn new directory name (string) 2398 @type str
2399 @param newdn new directory name
2400 @type str
2331 """ 2401 """
2332 olddn = self.getRelativePath(olddn) 2402 olddn = self.getRelativePath(olddn)
2333 newdn = self.getRelativePath(newdn) 2403 newdn = self.getRelativePath(newdn)
2334 typeStrings = [] 2404 typeStrings = []
2335 for fileCategory in [ 2405 for fileCategory in [
2364 Public slot to remove a file from the project. 2434 Public slot to remove a file from the project.
2365 2435
2366 The file is not deleted from the project directory. 2436 The file is not deleted from the project directory.
2367 2437
2368 @param fn filename to be removed from the project 2438 @param fn filename to be removed from the project
2369 @param updateModel flag indicating an update of the model is 2439 @type str
2370 requested (boolean) 2440 @param updateModel flag indicating an update of the model is requested
2441 @type bool
2371 """ 2442 """
2372 fn = self.getRelativePath(fn) 2443 fn = self.getRelativePath(fn)
2373 for fileCategory in self.getFileCategories(): 2444 for fileCategory in self.getFileCategories():
2374 if fn in self.__pdata[fileCategory]: 2445 if fn in self.__pdata[fileCategory]:
2375 self.__pdata[fileCategory].remove(fn) 2446 self.__pdata[fileCategory].remove(fn)
2384 Public method to remove a directory from the project. 2455 Public method to remove a directory from the project.
2385 2456
2386 The directory is not deleted from the project directory. 2457 The directory is not deleted from the project directory.
2387 2458
2388 @param dn directory name to be removed from the project 2459 @param dn directory name to be removed from the project
2460 @type str
2389 """ 2461 """
2390 dirty = False 2462 dirty = False
2391 dn = self.getRelativePath(dn) 2463 dn = self.getRelativePath(dn)
2392 for entry in self.__pdata["OTHERS"][:]: 2464 for entry in self.__pdata["OTHERS"][:]:
2393 if entry.startswith(dn): 2465 if entry.startswith(dn):
2407 def deleteFile(self, fn): 2479 def deleteFile(self, fn):
2408 """ 2480 """
2409 Public method to delete a file from the project directory. 2481 Public method to delete a file from the project directory.
2410 2482
2411 @param fn filename to be deleted from the project 2483 @param fn filename to be deleted from the project
2412 @return flag indicating success (boolean) 2484 @type str
2485 @return flag indicating success
2486 @rtype bool
2413 """ 2487 """
2414 try: 2488 try:
2415 os.remove(os.path.join(self.ppath, fn)) 2489 os.remove(os.path.join(self.ppath, fn))
2416 path, ext = os.path.splitext(fn) 2490 path, ext = os.path.splitext(fn)
2417 if ext == ".ui": 2491 if ext == ".ui":
2447 def deleteDirectory(self, dn): 2521 def deleteDirectory(self, dn):
2448 """ 2522 """
2449 Public method to delete a directory from the project directory. 2523 Public method to delete a directory from the project directory.
2450 2524
2451 @param dn directory name to be removed from the project 2525 @param dn directory name to be removed from the project
2452 @return flag indicating success (boolean) 2526 @type str
2527 @return flag indicating success
2528 @rtype bool
2453 """ 2529 """
2454 if not os.path.isabs(dn): 2530 if not os.path.isabs(dn):
2455 dn = os.path.join(self.ppath, dn) 2531 dn = os.path.join(self.ppath, dn)
2456 try: 2532 try:
2457 shutil.rmtree(dn, True) 2533 shutil.rmtree(dn, ignore_errors=True)
2458 except OSError as err: 2534 except OSError as err:
2459 EricMessageBox.critical( 2535 EricMessageBox.critical(
2460 self.ui, 2536 self.ui,
2461 self.tr("Delete directory"), 2537 self.tr("Delete directory"),
2462 self.tr( 2538 self.tr(
2471 2547
2472 def hasEntry(self, fn): 2548 def hasEntry(self, fn):
2473 """ 2549 """
2474 Public method to check the project for a file. 2550 Public method to check the project for a file.
2475 2551
2476 @param fn filename to be checked (string) 2552 @param fn filename to be checked
2477 @return flag indicating, if the project contains the file (boolean) 2553 @type str
2554 @return flag indicating, if the project contains the file
2555 @rtype bool
2478 """ 2556 """
2479 fn = self.getRelativePath(fn) 2557 fn = self.getRelativePath(fn)
2480 return any( 2558 return any(
2481 fn in self.__pdata[category] 2559 fn in self.__pdata[category]
2482 for category in self.getFileCategories() 2560 for category in self.getFileCategories()
2774 ericApp() 2852 ericApp()
2775 .getObject("PluginManager") 2853 .getObject("PluginManager")
2776 .getPluginDisplayStrings("version_control") 2854 .getPluginDisplayStrings("version_control")
2777 ) 2855 )
2778 vcsSystemsDisplay = [self.tr("None")] 2856 vcsSystemsDisplay = [self.tr("None")]
2779 keys = sorted(vcsSystemsDict.keys()) 2857 for key in sorted(vcsSystemsDict):
2780 for key in keys:
2781 vcsSystemsDisplay.append(vcsSystemsDict[key]) 2858 vcsSystemsDisplay.append(vcsSystemsDict[key])
2782 vcsSelected, ok = QInputDialog.getItem( 2859 vcsSelected, ok = QInputDialog.getItem(
2783 None, 2860 None,
2784 self.tr("New Project"), 2861 self.tr("New Project"),
2785 self.tr("Select version control system for the project"), 2862 self.tr("Select version control system for the project"),
2855 2932
2856 def newProjectAddFiles(self, mainscript): 2933 def newProjectAddFiles(self, mainscript):
2857 """ 2934 """
2858 Public method to add files to a new project. 2935 Public method to add files to a new project.
2859 2936
2860 @param mainscript name of the mainscript (string) 2937 @param mainscript name of the mainscript
2938 @type str
2861 """ 2939 """
2862 # Show the file type associations for the user to change 2940 # Show the file type associations for the user to change
2863 self.__showFiletypeAssociations() 2941 self.__showFiletypeAssociations()
2864 2942
2865 ignoreList = [] 2943 ignoreList = []
2868 if environmentPath: 2946 if environmentPath:
2869 # there is already an embeded venv; ignore thie whenn adding files 2947 # there is already an embeded venv; ignore thie whenn adding files
2870 ignoreList = [os.path.split(environmentPath)[-1]] 2948 ignoreList = [os.path.split(environmentPath)[-1]]
2871 with EricOverrideCursor(): 2949 with EricOverrideCursor():
2872 # search the project directory for files with known extensions 2950 # search the project directory for files with known extensions
2873 filespecs = list(self.__pdata["FILETYPES"].keys()) 2951 for filespec in self.__pdata["FILETYPES"]:
2874 for filespec in filespecs:
2875 files = FileSystemUtilities.direntries( 2952 files = FileSystemUtilities.direntries(
2876 self.ppath, 2953 self.ppath,
2877 filesonly=True, 2954 filesonly=True,
2878 pattern=filespec, 2955 pattern=filespec,
2879 ignore=ignoreList, 2956 ignore=ignoreList,
3116 def getEditorLexerAssoc(self, filename): 3193 def getEditorLexerAssoc(self, filename):
3117 """ 3194 """
3118 Public method to retrieve a lexer association. 3195 Public method to retrieve a lexer association.
3119 3196
3120 @param filename filename used to determine the associated lexer 3197 @param filename filename used to determine the associated lexer
3121 language (string) 3198 language
3122 @return the requested lexer language (string) 3199 @type str
3200 @return the requested lexer language
3201 @rtype str
3123 """ 3202 """
3124 # try user settings first 3203 # try user settings first
3125 for pattern, language in list(self.__pdata["LEXERASSOCS"].items()): 3204 for pattern, language in self.__pdata["LEXERASSOCS"].items():
3126 if fnmatch.fnmatch(filename, pattern): 3205 if fnmatch.fnmatch(filename, pattern):
3127 return language 3206 return language
3128 3207
3129 # try project type specific defaults next 3208 # try project type specific defaults next
3130 projectType = self.__pdata["PROJECTTYPE"] 3209 projectType = self.__pdata["PROJECTTYPE"]
3150 def openProject(self, fn=None, restoreSession=True, reopen=False): 3229 def openProject(self, fn=None, restoreSession=True, reopen=False):
3151 """ 3230 """
3152 Public slot to open a project. 3231 Public slot to open a project.
3153 3232
3154 @param fn optional filename of the project file to be read 3233 @param fn optional filename of the project file to be read
3234 @type str
3155 @param restoreSession flag indicating to restore the project 3235 @param restoreSession flag indicating to restore the project
3156 session (boolean) 3236 session
3157 @param reopen flag indicating a reopening of the project (boolean) 3237 @type bool
3238 @param reopen flag indicating a reopening of the project
3239 @type bool
3158 """ 3240 """
3159 if not self.checkDirty(): 3241 if not self.checkDirty():
3160 return 3242 return
3161 3243
3162 if fn is None: 3244 if fn is None:
3334 def saveProject(self): 3416 def saveProject(self):
3335 """ 3417 """
3336 Public slot to save the current project. 3418 Public slot to save the current project.
3337 3419
3338 @return flag indicating success 3420 @return flag indicating success
3421 @rtype bool
3339 """ 3422 """
3340 if self.isDirty(): 3423 if self.isDirty():
3341 if len(self.pfile) > 0: 3424 if len(self.pfile) > 0:
3342 if self.pfile.endswith(".e4p"): 3425 if self.pfile.endswith(".e4p"):
3343 self.pfile = self.pfile.replace(".e4p", ".epj") 3426 self.pfile = self.pfile.replace(".e4p", ".epj")
3353 3436
3354 def saveProjectAs(self): 3437 def saveProjectAs(self):
3355 """ 3438 """
3356 Public slot to save the current project to a different file. 3439 Public slot to save the current project to a different file.
3357 3440
3358 @return flag indicating success (boolean) 3441 @return flag indicating success
3442 @rtype bool
3359 """ 3443 """
3360 defaultFilter = self.tr("Project Files (*.epj)") 3444 defaultFilter = self.tr("Project Files (*.epj)")
3361 defaultPath = ( 3445 defaultPath = (
3362 self.ppath 3446 self.ppath
3363 if self.ppath 3447 if self.ppath
3413 3497
3414 def checkDirty(self): 3498 def checkDirty(self):
3415 """ 3499 """
3416 Public method to check dirty status and open a message window. 3500 Public method to check dirty status and open a message window.
3417 3501
3418 @return flag indicating whether this operation was successful (boolean) 3502 @return flag indicating whether this operation was successful
3503 @rtype bool
3419 """ 3504 """
3420 if self.isDirty(): 3505 if self.isDirty():
3421 res = EricMessageBox.okToClearData( 3506 res = EricMessageBox.okToClearData(
3422 self.parent(), 3507 self.parent(),
3423 self.tr("Close Project"), 3508 self.tr("Close Project"),
3557 def saveAllScripts(self, reportSyntaxErrors=False): 3642 def saveAllScripts(self, reportSyntaxErrors=False):
3558 """ 3643 """
3559 Public method to save all scripts belonging to the project. 3644 Public method to save all scripts belonging to the project.
3560 3645
3561 @param reportSyntaxErrors flag indicating special reporting 3646 @param reportSyntaxErrors flag indicating special reporting
3562 for syntax errors (boolean) 3647 for syntax errors
3563 @return flag indicating success (boolean) 3648 @type bool
3649 @return flag indicating success
3650 @rtype bool
3564 """ 3651 """
3565 vm = ericApp().getObject("ViewManager") 3652 vm = ericApp().getObject("ViewManager")
3566 success = True 3653 success = True
3567 filesWithSyntaxErrors = 0 3654 filesWithSyntaxErrors = 0
3568 for fn in vm.getOpenFilenames(): 3655 for fn in vm.getOpenFilenames():
3591 """ 3678 """
3592 Public method to check all scripts belonging to the project for 3679 Public method to check all scripts belonging to the project for
3593 their dirty status. 3680 their dirty status.
3594 3681
3595 @param reportSyntaxErrors flag indicating special reporting 3682 @param reportSyntaxErrors flag indicating special reporting
3596 for syntax errors (boolean) 3683 for syntax errors
3597 @return flag indicating success (boolean) 3684 @type bool
3685 @return flag indicating success
3686 @rtype bool
3598 """ 3687 """
3599 vm = ericApp().getObject("ViewManager") 3688 vm = ericApp().getObject("ViewManager")
3600 success = True 3689 success = True
3601 filesWithSyntaxErrors = 0 3690 filesWithSyntaxErrors = 0
3602 for fn in vm.getOpenFilenames(): 3691 for fn in vm.getOpenFilenames():
3674 3763
3675 def getProjectType(self): 3764 def getProjectType(self):
3676 """ 3765 """
3677 Public method to get the type of the project. 3766 Public method to get the type of the project.
3678 3767
3679 @return UI type of the project (string) 3768 @return UI type of the project
3769 @rtype str
3680 """ 3770 """
3681 return self.__pdata["PROJECTTYPE"] 3771 return self.__pdata["PROJECTTYPE"]
3682 3772
3683 def getProjectLanguage(self): 3773 def getProjectLanguage(self):
3684 """ 3774 """
3685 Public method to get the project's programming language. 3775 Public method to get the project's programming language.
3686 3776
3687 @return programming language (string) 3777 @return programming language
3778 @rtype str
3688 """ 3779 """
3689 return self.__pdata["PROGLANGUAGE"] 3780 return self.__pdata["PROGLANGUAGE"]
3690 3781
3691 def isMixedLanguageProject(self): 3782 def isMixedLanguageProject(self):
3692 """ 3783 """
3700 def isPythonProject(self): 3791 def isPythonProject(self):
3701 """ 3792 """
3702 Public method to check, if this project is a Python3 or MicroPython 3793 Public method to check, if this project is a Python3 or MicroPython
3703 project. 3794 project.
3704 3795
3705 @return flag indicating a Python project (boolean) 3796 @return flag indicating a Python project
3797 @rtype bool
3706 """ 3798 """
3707 return self.__pdata["PROGLANGUAGE"] in ["Python3", "MicroPython"] 3799 return self.__pdata["PROGLANGUAGE"] in ["Python3", "MicroPython"]
3708 3800
3709 def isPy3Project(self): 3801 def isPy3Project(self):
3710 """ 3802 """
3711 Public method to check, if this project is a Python3 project. 3803 Public method to check, if this project is a Python3 project.
3712 3804
3713 @return flag indicating a Python3 project (boolean) 3805 @return flag indicating a Python3 project
3806 @rtype bool
3714 """ 3807 """
3715 return self.__pdata["PROGLANGUAGE"] == "Python3" 3808 return self.__pdata["PROGLANGUAGE"] == "Python3"
3716 3809
3717 def isMicroPythonProject(self): 3810 def isMicroPythonProject(self):
3718 """ 3811 """
3725 3818
3726 def isRubyProject(self): 3819 def isRubyProject(self):
3727 """ 3820 """
3728 Public method to check, if this project is a Ruby project. 3821 Public method to check, if this project is a Ruby project.
3729 3822
3730 @return flag indicating a Ruby project (boolean) 3823 @return flag indicating a Ruby project
3824 @rtype bool
3731 """ 3825 """
3732 return self.__pdata["PROGLANGUAGE"] == "Ruby" 3826 return self.__pdata["PROGLANGUAGE"] == "Ruby"
3733 3827
3734 def isJavaScriptProject(self): 3828 def isJavaScriptProject(self):
3735 """ 3829 """
3736 Public method to check, if this project is a JavaScript project. 3830 Public method to check, if this project is a JavaScript project.
3737 3831
3738 @return flag indicating a JavaScript project (boolean) 3832 @return flag indicating a JavaScript project
3833 @rtype bool
3739 """ 3834 """
3740 return self.__pdata["PROGLANGUAGE"] == "JavaScript" 3835 return self.__pdata["PROGLANGUAGE"] == "JavaScript"
3741 3836
3742 def getProjectSpellLanguage(self): 3837 def getProjectSpellLanguage(self):
3743 """ 3838 """
3744 Public method to get the project's programming language. 3839 Public method to get the project's programming language.
3745 3840
3746 @return programming language (string) 3841 @return programming language
3842 @rtype str
3747 """ 3843 """
3748 return self.__pdata["SPELLLANGUAGE"] 3844 return self.__pdata["SPELLLANGUAGE"]
3749 3845
3750 def getProjectDictionaries(self): 3846 def getProjectDictionaries(self):
3751 """ 3847 """
3752 Public method to get the names of the project specific dictionaries. 3848 Public method to get the names of the project specific dictionaries.
3753 3849
3754 @return tuple of two strings giving the absolute path names of the 3850 @return tuple containing the absolute path names of the project specific
3755 project specific word and exclude list 3851 word and exclude list
3852 @rtype tuple of (str, str)
3756 """ 3853 """
3757 pwl = "" 3854 pwl = ""
3758 if self.__pdata["SPELLWORDS"]: 3855 if self.__pdata["SPELLWORDS"]:
3759 pwl = os.path.join(self.ppath, self.__pdata["SPELLWORDS"]) 3856 pwl = os.path.join(self.ppath, self.__pdata["SPELLWORDS"])
3760 if not os.path.isfile(pwl): 3857 if not os.path.isfile(pwl):
3771 def getDefaultSourceExtension(self): 3868 def getDefaultSourceExtension(self):
3772 """ 3869 """
3773 Public method to get the default extension for the project's 3870 Public method to get the default extension for the project's
3774 programming language. 3871 programming language.
3775 3872
3776 @return default extension (including the dot) (string) 3873 @return default extension (including the dot)
3874 @rtype str
3777 """ 3875 """
3778 lang = self.__pdata["PROGLANGUAGE"] 3876 lang = self.__pdata["PROGLANGUAGE"]
3779 if lang in ("", "Python"): 3877 if lang in ("", "Python"):
3780 lang = "Python3" 3878 lang = "Python3"
3781 return self.__sourceExtensions(lang)[0] 3879 return self.__sourceExtensions(lang)[0]
3782 3880
3783 def getProjectPath(self): 3881 def getProjectPath(self):
3784 """ 3882 """
3785 Public method to get the project path. 3883 Public method to get the project path.
3786 3884
3787 @return project path (string) 3885 @return project path
3886 @rtype str
3788 """ 3887 """
3789 return self.ppath 3888 return self.ppath
3790 3889
3791 def startswithProjectPath(self, path): 3890 def startswithProjectPath(self, path):
3792 """ 3891 """
3810 3909
3811 def getProjectFile(self): 3910 def getProjectFile(self):
3812 """ 3911 """
3813 Public method to get the path of the project file. 3912 Public method to get the path of the project file.
3814 3913
3815 @return path of the project file (string) 3914 @return path of the project file
3915 @rtype str
3816 """ 3916 """
3817 return self.pfile 3917 return self.pfile
3818 3918
3819 def getProjectName(self): 3919 def getProjectName(self):
3820 """ 3920 """
3821 Public method to get the name of the project. 3921 Public method to get the name of the project.
3822 3922
3823 The project name is determined from the name of the project file. 3923 The project name is determined from the name of the project file.
3824 3924
3825 @return name of the project (string) 3925 @return name of the project
3926 @rtype str
3826 """ 3927 """
3827 if self.pfile: 3928 if self.pfile:
3828 name = os.path.splitext(self.pfile)[0] 3929 name = os.path.splitext(self.pfile)[0]
3829 return os.path.basename(name) 3930 return os.path.basename(name)
3830 else: 3931 else:
3832 3933
3833 def getProjectManagementDir(self): 3934 def getProjectManagementDir(self):
3834 """ 3935 """
3835 Public method to get the path of the management directory. 3936 Public method to get the path of the management directory.
3836 3937
3837 @return path of the management directory (string) 3938 @return path of the management directory
3939 @rtype str
3838 """ 3940 """
3839 return os.path.join(self.ppath, ".eric7project") 3941 return os.path.join(self.ppath, ".eric7project")
3840 3942
3841 def createProjectManagementDir(self): 3943 def createProjectManagementDir(self):
3842 """ 3944 """
3851 3953
3852 def getHash(self): 3954 def getHash(self):
3853 """ 3955 """
3854 Public method to get the project hash. 3956 Public method to get the project hash.
3855 3957
3856 @return project hash as a hex string (string) 3958 @return project hash as a hex string
3959 @rtype str
3857 """ 3960 """
3858 return self.__pdata["HASH"] 3961 return self.__pdata["HASH"]
3859 3962
3860 def getRelativePath(self, path): 3963 def getRelativePath(self, path):
3861 """ 3964 """
3862 Public method to convert a file path to a project relative 3965 Public method to convert a file path to a project relative
3863 file path. 3966 file path.
3864 3967
3865 @param path file or directory name to convert (string) 3968 @param path file or directory name to convert
3969 @type str
3866 @return project relative path or unchanged path, if path doesn't 3970 @return project relative path or unchanged path, if path doesn't
3867 belong to the project (string) 3971 belong to the project
3972 @rtype str
3868 """ 3973 """
3869 if path is None: 3974 if path is None:
3870 return "" 3975 return ""
3871 3976
3872 try: 3977 try:
3877 def getRelativeUniversalPath(self, path): 3982 def getRelativeUniversalPath(self, path):
3878 """ 3983 """
3879 Public method to convert a file path to a project relative 3984 Public method to convert a file path to a project relative
3880 file path with universal separators. 3985 file path with universal separators.
3881 3986
3882 @param path file or directory name to convert (string) 3987 @param path file or directory name to convert
3988 @type str
3883 @return project relative path or unchanged path, if path doesn't 3989 @return project relative path or unchanged path, if path doesn't
3884 belong to the project (string) 3990 belong to the project
3991 @rtype str
3885 """ 3992 """
3886 return FileSystemUtilities.fromNativeSeparators(self.getRelativePath(path)) 3993 return FileSystemUtilities.fromNativeSeparators(self.getRelativePath(path))
3887 3994
3888 def getAbsolutePath(self, fn): 3995 def getAbsolutePath(self, fn):
3889 """ 3996 """
3890 Public method to convert a project relative file path to an absolute 3997 Public method to convert a project relative file path to an absolute
3891 file path. 3998 file path.
3892 3999
3893 @param fn file or directory name to convert (string) 4000 @param fn file or directory name to convert
3894 @return absolute path (string) 4001 @type str
4002 @return absolute path
4003 @rtype str
3895 """ 4004 """
3896 if not os.path.isabs(fn): 4005 if not os.path.isabs(fn):
3897 fn = os.path.join(self.ppath, fn) 4006 fn = os.path.join(self.ppath, fn)
3898 return fn 4007 return fn
3899 4008
3900 def getAbsoluteUniversalPath(self, fn): 4009 def getAbsoluteUniversalPath(self, fn):
3901 """ 4010 """
3902 Public method to convert a project relative file path with universal 4011 Public method to convert a project relative file path with universal
3903 separators to an absolute file path. 4012 separators to an absolute file path.
3904 4013
3905 @param fn file or directory name to convert (string) 4014 @param fn file or directory name to convert
3906 @return absolute path (string) 4015 @type str
4016 @return absolute path
4017 @rtype str
3907 """ 4018 """
3908 if not os.path.isabs(fn): 4019 if not os.path.isabs(fn):
3909 fn = os.path.join(self.ppath, FileSystemUtilities.toNativeSeparators(fn)) 4020 fn = os.path.join(self.ppath, FileSystemUtilities.toNativeSeparators(fn))
3910 return fn 4021 return fn
3911 4022
3912 def getEolString(self): 4023 def getEolString(self):
3913 """ 4024 """
3914 Public method to get the EOL-string to be used by the project. 4025 Public method to get the EOL-string to be used by the project.
3915 4026
3916 @return eol string (string) 4027 @return eol string
4028 @rtype str
3917 """ 4029 """
3918 if self.__pdata["EOL"] >= 0: 4030 if self.__pdata["EOL"] >= 0:
3919 return self.eols[self.__pdata["EOL"]] 4031 return self.eols[self.__pdata["EOL"]]
3920 else: 4032 else:
3921 eolMode = Preferences.getEditor("EOLMode") 4033 eolMode = Preferences.getEditor("EOLMode")
3931 4043
3932 def useSystemEol(self): 4044 def useSystemEol(self):
3933 """ 4045 """
3934 Public method to check, if the project uses the system eol setting. 4046 Public method to check, if the project uses the system eol setting.
3935 4047
3936 @return flag indicating the usage of system eol (boolean) 4048 @return flag indicating the usage of system eol
4049 @rtype bool
3937 """ 4050 """
3938 return self.__pdata["EOL"] == 0 4051 return self.__pdata["EOL"] == 0
3939 4052
3940 def getProjectVersion(self): 4053 def getProjectVersion(self):
3941 """ 4054 """
4103 def isProjectFile(self, fn): 4216 def isProjectFile(self, fn):
4104 """ 4217 """
4105 Public method used to check, if the passed in filename belongs to the 4218 Public method used to check, if the passed in filename belongs to the
4106 project. 4219 project.
4107 4220
4108 @param fn filename to be checked (string) 4221 @param fn filename to be checked
4109 @return flag indicating membership (boolean) 4222 @type str
4223 @return flag indicating membership
4224 @rtype bool
4110 """ 4225 """
4111 return any( 4226 return any(
4112 self.__checkProjectFileGroup(fn, category) 4227 self.__checkProjectFileGroup(fn, category)
4113 for category in self.getFileCategories() 4228 for category in self.getFileCategories()
4114 ) 4229 )
4116 def __checkProjectFileGroup(self, fn, group): 4231 def __checkProjectFileGroup(self, fn, group):
4117 """ 4232 """
4118 Private method to check, if a file is in a specific file group of the 4233 Private method to check, if a file is in a specific file group of the
4119 project. 4234 project.
4120 4235
4121 @param fn filename to be checked (string) 4236 @param fn filename to be checked
4122 @param group group to check (string) 4237 @type str
4123 @return flag indicating membership (boolean) 4238 @param group group to check
4239 @type str
4240 @return flag indicating membership
4241 @rtype bool
4124 """ 4242 """
4125 newfn = os.path.abspath(fn) 4243 newfn = os.path.abspath(fn)
4126 newfn = self.getRelativePath(newfn) 4244 newfn = self.getRelativePath(newfn)
4127 if newfn in self.__pdata[group] or ( 4245 if newfn in self.__pdata[group] or (
4128 group == "OTHERS" 4246 group == "OTHERS"
4209 self.actions.append(act) 4327 self.actions.append(act)
4210 4328
4211 self.reloadAct = EricAction( 4329 self.reloadAct = EricAction(
4212 self.tr("Reload project"), 4330 self.tr("Reload project"),
4213 EricPixmapCache.getIcon("projectReload"), 4331 EricPixmapCache.getIcon("projectReload"),
4214 self.tr("&Reload"), 4332 self.tr("Re&load"),
4215 0, 4333 0,
4216 0, 4334 0,
4217 self.actGrp1, 4335 self.actGrp1,
4218 "project_reload", 4336 "project_reload",
4219 ) 4337 )
5416 """ 5534 """
5417 Public slot to initialize the project toolbar and the basic VCS 5535 Public slot to initialize the project toolbar and the basic VCS
5418 toolbar. 5536 toolbar.
5419 5537
5420 @param toolbarManager reference to a toolbar manager object 5538 @param toolbarManager reference to a toolbar manager object
5421 (EricToolBarManager) 5539 @type EricToolBarManager
5422 @return tuple of the generated toolbars (tuple of two QToolBar) 5540 @return tuple of the generated toolbars
5541 @rtype tuple of two QToolBar
5423 """ 5542 """
5424 from eric7 import VCS 5543 from eric7 import VCS
5425 5544
5426 tb = QToolBar(self.tr("Project"), self.ui) 5545 tb = QToolBar(self.tr("Project"), self.ui)
5427 tb.setObjectName("ProjectToolbar") 5546 tb.setObjectName("ProjectToolbar")
5491 def __openRecent(self, act): 5610 def __openRecent(self, act):
5492 """ 5611 """
5493 Private method to open a project from the list of rencently opened 5612 Private method to open a project from the list of rencently opened
5494 projects. 5613 projects.
5495 5614
5496 @param act reference to the action that triggered (QAction) 5615 @param act reference to the action that triggered
5616 @type QAction
5497 """ 5617 """
5498 file = act.data() 5618 file = act.data()
5499 if file: 5619 if file:
5500 self.openProject(file) 5620 self.openProject(file)
5501 5621
5545 gives the user the opportunity to select the ones he wants to 5665 gives the user the opportunity to select the ones he wants to
5546 include. If 'Automatic Inclusion' is enabled, the new files are 5666 include. If 'Automatic Inclusion' is enabled, the new files are
5547 automatically added to the project. 5667 automatically added to the project.
5548 5668
5549 @param AI flag indicating whether the automatic inclusion should 5669 @param AI flag indicating whether the automatic inclusion should
5550 be honoured (boolean) 5670 be honoured
5671 @type bool
5551 @param onUserDemand flag indicating whether this method was 5672 @param onUserDemand flag indicating whether this method was
5552 requested by the user via a menu action (boolean) 5673 requested by the user via a menu action
5674 @type bool
5553 """ 5675 """
5554 from .AddFoundFilesDialog import AddFoundFilesDialog 5676 from .AddFoundFilesDialog import AddFoundFilesDialog
5555 5677
5556 autoInclude = Preferences.getProject("AutoIncludeNewFiles") 5678 autoInclude = Preferences.getProject("AutoIncludeNewFiles")
5557 recursiveSearch = Preferences.getProject("SearchNewFilesRecursively") 5679 recursiveSearch = Preferences.getProject("SearchNewFilesRecursively")
5610 dirs.append(d) 5732 dirs.append(d)
5611 continue 5733 continue
5612 5734
5613 filetype = "" 5735 filetype = ""
5614 bfn = os.path.basename(fn) 5736 bfn = os.path.basename(fn)
5615 for pattern in sorted(self.__pdata["FILETYPES"].keys(), reverse=True): 5737 for pattern in sorted(self.__pdata["FILETYPES"], reverse=True):
5616 if fnmatch.fnmatch(bfn, pattern): 5738 if fnmatch.fnmatch(bfn, pattern):
5617 filetype = self.__pdata["FILETYPES"][pattern] 5739 filetype = self.__pdata["FILETYPES"][pattern]
5618 break 5740 break
5619 5741
5620 if ( 5742 if (
5668 def othersAdded(self, fn, updateModel=True): 5790 def othersAdded(self, fn, updateModel=True):
5669 """ 5791 """
5670 Public slot to be called, if something was added to the OTHERS project 5792 Public slot to be called, if something was added to the OTHERS project
5671 data area. 5793 data area.
5672 5794
5673 @param fn filename or directory name added (string) 5795 @param fn filename or directory name added
5796 @type str
5674 @param updateModel flag indicating an update of the model is requested 5797 @param updateModel flag indicating an update of the model is requested
5675 (boolean) 5798 @type bool
5676 """ 5799 """
5677 self.projectFileAdded.emit(fn, "OTHERS") 5800 self.projectFileAdded.emit(fn, "OTHERS")
5678 updateModel and self.__model.addNewItem("OTHERS", fn) 5801 updateModel and self.__model.addNewItem("OTHERS", fn)
5679 5802
5680 def getActions(self): 5803 def getActions(self):
5681 """ 5804 """
5682 Public method to get a list of all actions. 5805 Public method to get a list of all actions.
5683 5806
5684 @return list of all actions (list of EricAction) 5807 @return list of all actions
5808 @rtype list of EricAction
5685 """ 5809 """
5686 return self.actions[:] 5810 return self.actions[:]
5687 5811
5688 def addEricActions(self, actions): 5812 def addEricActions(self, actions):
5689 """ 5813 """
5690 Public method to add actions to the list of actions. 5814 Public method to add actions to the list of actions.
5691 5815
5692 @param actions list of actions (list of EricAction) 5816 @param actions list of actions
5817 @type list of EricAction
5693 """ 5818 """
5694 self.actions.extend(actions) 5819 self.actions.extend(actions)
5695 5820
5696 def removeEricActions(self, actions): 5821 def removeEricActions(self, actions):
5697 """ 5822 """
5698 Public method to remove actions from the list of actions. 5823 Public method to remove actions from the list of actions.
5699 5824
5700 @param actions list of actions (list of EricAction) 5825 @param actions list of actions
5826 @type list of EricAction
5701 """ 5827 """
5702 for act in actions: 5828 for act in actions:
5703 with contextlib.suppress(ValueError): 5829 with contextlib.suppress(ValueError):
5704 self.actions.remove(act) 5830 self.actions.remove(act)
5705 5831
5706 def getMenu(self, menuName): 5832 def getMenu(self, menuName):
5707 """ 5833 """
5708 Public method to get a reference to the main menu or a submenu. 5834 Public method to get a reference to the main menu or a submenu.
5709 5835
5710 @param menuName name of the menu (string) 5836 @param menuName name of the menu
5711 @return reference to the requested menu (QMenu) or None 5837 @type str
5838 @return reference to the requested menu or None
5839 @rtype QMenu
5712 """ 5840 """
5713 try: 5841 try:
5714 return self.__menus[menuName] 5842 return self.__menus[menuName]
5715 except KeyError: 5843 except KeyError:
5716 return None 5844 return None
5717 5845
5718 def repopulateItem(self, fullname): 5846 def repopulateItem(self, fullname):
5719 """ 5847 """
5720 Public slot to repopulate a named item. 5848 Public slot to repopulate a named item.
5721 5849
5722 @param fullname full name of the item to repopulate (string) 5850 @param fullname full name of the item to repopulate
5851 @type str
5723 """ 5852 """
5724 if not self.isOpen(): 5853 if not self.isOpen():
5725 return 5854 return
5726 5855
5727 with EricOverrideCursor(): 5856 with EricOverrideCursor():
5736 5865
5737 def initVCS(self, vcsSystem=None, nooverride=False): 5866 def initVCS(self, vcsSystem=None, nooverride=False):
5738 """ 5867 """
5739 Public method used to instantiate a vcs system. 5868 Public method used to instantiate a vcs system.
5740 5869
5741 @param vcsSystem type of VCS to be used (string) 5870 @param vcsSystem type of VCS to be used
5871 @type str
5742 @param nooverride flag indicating to ignore an override request 5872 @param nooverride flag indicating to ignore an override request
5743 (boolean) 5873 @type bool
5744 @return a reference to the vcs object 5874 @return a reference to the vcs object
5875 @rtype VersionControl
5745 """ 5876 """
5746 from eric7 import VCS 5877 from eric7 import VCS
5747 5878
5748 vcs = None 5879 vcs = None
5749 forProject = True 5880 forProject = True
5852 def vcsSoftwareAvailable(self): 5983 def vcsSoftwareAvailable(self):
5853 """ 5984 """
5854 Public method to check, if some supported VCS software is available 5985 Public method to check, if some supported VCS software is available
5855 to the IDE. 5986 to the IDE.
5856 5987
5857 @return flag indicating availability of VCS software (boolean) 5988 @return flag indicating availability of VCS software
5989 @rtype bool
5858 """ 5990 """
5859 vcsSystemsDict = ( 5991 vcsSystemsDict = (
5860 ericApp() 5992 ericApp()
5861 .getObject("PluginManager") 5993 .getObject("PluginManager")
5862 .getPluginDisplayStrings("version_control") 5994 .getPluginDisplayStrings("version_control")
6082 6214
6083 def setStatusMonitorInterval(self, interval): 6215 def setStatusMonitorInterval(self, interval):
6084 """ 6216 """
6085 Public method to se the interval of the VCS status monitor thread. 6217 Public method to se the interval of the VCS status monitor thread.
6086 6218
6087 @param interval status monitor interval in seconds (integer) 6219 @param interval status monitor interval in seconds
6220 @type int
6088 """ 6221 """
6089 if self.vcs is not None: 6222 if self.vcs is not None:
6090 self.vcs.setStatusMonitorInterval(interval, self) 6223 self.vcs.setStatusMonitorInterval(interval, self)
6091 6224
6092 def getStatusMonitorInterval(self): 6225 def getStatusMonitorInterval(self):
6093 """ 6226 """
6094 Public method to get the monitor interval. 6227 Public method to get the monitor interval.
6095 6228
6096 @return interval in seconds (integer) 6229 @return interval in seconds
6230 @rtype int
6097 """ 6231 """
6098 if self.vcs is not None: 6232 if self.vcs is not None:
6099 return self.vcs.getStatusMonitorInterval() 6233 return self.vcs.getStatusMonitorInterval()
6100 else: 6234 else:
6101 return 0 6235 return 0
6102 6236
6103 def setStatusMonitorAutoUpdate(self, auto): 6237 def setStatusMonitorAutoUpdate(self, auto):
6104 """ 6238 """
6105 Public method to enable the auto update function. 6239 Public method to enable the auto update function.
6106 6240
6107 @param auto status of the auto update function (boolean) 6241 @param auto status of the auto update function
6242 @type bool
6108 """ 6243 """
6109 if self.vcs is not None: 6244 if self.vcs is not None:
6110 self.vcs.setStatusMonitorAutoUpdate(auto) 6245 self.vcs.setStatusMonitorAutoUpdate(auto)
6111 6246
6112 def getStatusMonitorAutoUpdate(self): 6247 def getStatusMonitorAutoUpdate(self):
6113 """ 6248 """
6114 Public method to retrieve the status of the auto update function. 6249 Public method to retrieve the status of the auto update function.
6115 6250
6116 @return status of the auto update function (boolean) 6251 @return status of the auto update function
6252 @rtype bool
6117 """ 6253 """
6118 if self.vcs is not None: 6254 if self.vcs is not None:
6119 return self.vcs.getStatusMonitorAutoUpdate() 6255 return self.vcs.getStatusMonitorAutoUpdate()
6120 else: 6256 else:
6121 return False 6257 return False
6129 6265
6130 def clearStatusMonitorCachedState(self, name): 6266 def clearStatusMonitorCachedState(self, name):
6131 """ 6267 """
6132 Public method to clear the cached VCS state of a file/directory. 6268 Public method to clear the cached VCS state of a file/directory.
6133 6269
6134 @param name name of the entry to be cleared (string) 6270 @param name name of the entry to be cleared
6271 @type str
6135 """ 6272 """
6136 if self.vcs is not None: 6273 if self.vcs is not None:
6137 self.vcs.clearStatusMonitorCachedState(name) 6274 self.vcs.clearStatusMonitorCachedState(name)
6138 6275
6139 def startStatusMonitor(self): 6276 def startStatusMonitor(self):
6231 @pyqtSlot() 6368 @pyqtSlot()
6232 def __pluginCreateArchives(self, snapshot=False): 6369 def __pluginCreateArchives(self, snapshot=False):
6233 """ 6370 """
6234 Private slot to create eric plugin archives. 6371 Private slot to create eric plugin archives.
6235 6372
6236 @param snapshot flag indicating snapshot archives (boolean) 6373 @param snapshot flag indicating snapshot archives
6374 @type bool
6237 """ 6375 """
6238 if not self.__pdata["MAINSCRIPT"]: 6376 if not self.__pdata["MAINSCRIPT"]:
6239 EricMessageBox.critical( 6377 EricMessageBox.critical(
6240 self.ui, 6378 self.ui,
6241 self.tr("Create Plugin Archive"), 6379 self.tr("Create Plugin Archive"),
6433 6571
6434 def __createZipDirEntries(self, path, zipFile): 6572 def __createZipDirEntries(self, path, zipFile):
6435 """ 6573 """
6436 Private method to create dir entries in the zip file. 6574 Private method to create dir entries in the zip file.
6437 6575
6438 @param path name of the directory entry to create (string) 6576 @param path name of the directory entry to create
6439 @param zipFile open ZipFile object (zipfile.ZipFile) 6577 @type str
6578 @param zipFile open ZipFile object
6579 @type zipfile.ZipFile
6440 """ 6580 """
6441 if path in ("", "/", "\\"): 6581 if path in ("", "/", "\\"):
6442 return 6582 return
6443 6583
6444 if not path.endswith("/") and not path.endswith("\\"): 6584 if not path.endswith("/") and not path.endswith("\\"):
6454 6594
6455 The version entry in the plugin module is modified to signify 6595 The version entry in the plugin module is modified to signify
6456 a snapshot version. This method appends the string "-snapshot-" 6596 a snapshot version. This method appends the string "-snapshot-"
6457 and date indicator to the version string. 6597 and date indicator to the version string.
6458 6598
6459 @param filename name of the plugin file to modify (string) 6599 @param filename name of the plugin file to modify
6460 @return modified source (bytes), snapshot version string (string) 6600 @type str
6601 @return modified source (bytes), snapshot version string
6602 @rtype str
6461 """ 6603 """
6462 try: 6604 try:
6463 sourcelines, encoding = Utilities.readEncodedFile(filename) 6605 sourcelines, encoding = Utilities.readEncodedFile(filename)
6464 sourcelines = sourcelines.splitlines(True) 6606 sourcelines = sourcelines.splitlines(True)
6465 except (OSError, UnicodeError) as why: 6607 except (OSError, UnicodeError) as why:
6495 6637
6496 def __pluginExtractVersion(self, filename): 6638 def __pluginExtractVersion(self, filename):
6497 """ 6639 """
6498 Private method to extract the version number entry. 6640 Private method to extract the version number entry.
6499 6641
6500 @param filename name of the plugin file (string) 6642 @param filename name of the plugin file
6501 @return version string (string) 6643 @type str
6644 @return version string
6645 @rtype str
6502 """ 6646 """
6503 version = "0.0.0" 6647 version = "0.0.0"
6504 try: 6648 try:
6505 sourcelines = Utilities.readEncodedFile(filename)[0] 6649 sourcelines = Utilities.readEncodedFile(filename)[0]
6506 sourcelines = sourcelines.splitlines(True) 6650 sourcelines = sourcelines.splitlines(True)
6755 Public method to get a named uic related parameter. 6899 Public method to get a named uic related parameter.
6756 6900
6757 @param name name of the parameter 6901 @param name name of the parameter
6758 @type str 6902 @type str
6759 @return value of the given parameter 6903 @return value of the given parameter
6760 @rtype any, None in case on non-existence 6904 @rtype Any, None in case on non-existence
6761 """ 6905 """
6762 if name in self.__pdata["UICPARAMS"]: 6906 if name in self.__pdata["UICPARAMS"]:
6763 return self.__pdata["UICPARAMS"][name] 6907 return self.__pdata["UICPARAMS"][name]
6764 else: 6908 else:
6765 return None 6909 return None
7053 self.__venvConfiguration["system_site_packages"] = withSystemSitePackages 7197 self.__venvConfiguration["system_site_packages"] = withSystemSitePackages
7054 7198
7055 self.__configureEnvironment() 7199 self.__configureEnvironment()
7056 if not self.__venvConfiguration["interpreter"]: 7200 if not self.__venvConfiguration["interpreter"]:
7057 # user canceled the environment creation, delete the created directory 7201 # user canceled the environment creation, delete the created directory
7058 shutil.rmtree(configuration["targetDirectory"], True) 7202 shutil.rmtree(configuration["targetDirectory"], ignore_errors=True)
7059 self.__setEmbeddedEnvironmentProjectConfig(False) 7203 self.__setEmbeddedEnvironmentProjectConfig(False)
7060 return 7204 return
7061 7205
7062 if upgrade and not withSystemSitePackages: 7206 if upgrade and not withSystemSitePackages:
7063 # re-install the project into the upgraded environment 7207 # re-install the project into the upgraded environment

eric ide

mercurial