src/eric7/Project/Project.py

branch
eric7
changeset 10430
e440aaf179ce
parent 10417
c6011e501282
child 10439
21c28b0f9e41
equal deleted inserted replaced
10429:643989a1e2bd 10430:e440aaf179ce
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",
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
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 self.__pdata["FILETYPES"].items(): 2043 for pattern, patterntype in self.__pdata["FILETYPES"].items():
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"
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, ignore_errors=True) 2533 shutil.rmtree(dn, ignore_errors=True)
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()
2854 2932
2855 def newProjectAddFiles(self, mainscript): 2933 def newProjectAddFiles(self, mainscript):
2856 """ 2934 """
2857 Public method to add files to a new project. 2935 Public method to add files to a new project.
2858 2936
2859 @param mainscript name of the mainscript (string) 2937 @param mainscript name of the mainscript
2938 @type str
2860 """ 2939 """
2861 # Show the file type associations for the user to change 2940 # Show the file type associations for the user to change
2862 self.__showFiletypeAssociations() 2941 self.__showFiletypeAssociations()
2863 2942
2864 ignoreList = [] 2943 ignoreList = []
3114 def getEditorLexerAssoc(self, filename): 3193 def getEditorLexerAssoc(self, filename):
3115 """ 3194 """
3116 Public method to retrieve a lexer association. 3195 Public method to retrieve a lexer association.
3117 3196
3118 @param filename filename used to determine the associated lexer 3197 @param filename filename used to determine the associated lexer
3119 language (string) 3198 language
3120 @return the requested lexer language (string) 3199 @type str
3200 @return the requested lexer language
3201 @rtype str
3121 """ 3202 """
3122 # try user settings first 3203 # try user settings first
3123 for pattern, language in self.__pdata["LEXERASSOCS"].items(): 3204 for pattern, language in self.__pdata["LEXERASSOCS"].items():
3124 if fnmatch.fnmatch(filename, pattern): 3205 if fnmatch.fnmatch(filename, pattern):
3125 return language 3206 return language
3148 def openProject(self, fn=None, restoreSession=True, reopen=False): 3229 def openProject(self, fn=None, restoreSession=True, reopen=False):
3149 """ 3230 """
3150 Public slot to open a project. 3231 Public slot to open a project.
3151 3232
3152 @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
3153 @param restoreSession flag indicating to restore the project 3235 @param restoreSession flag indicating to restore the project
3154 session (boolean) 3236 session
3155 @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
3156 """ 3240 """
3157 if not self.checkDirty(): 3241 if not self.checkDirty():
3158 return 3242 return
3159 3243
3160 if fn is None: 3244 if fn is None:
3332 def saveProject(self): 3416 def saveProject(self):
3333 """ 3417 """
3334 Public slot to save the current project. 3418 Public slot to save the current project.
3335 3419
3336 @return flag indicating success 3420 @return flag indicating success
3421 @rtype bool
3337 """ 3422 """
3338 if self.isDirty(): 3423 if self.isDirty():
3339 if len(self.pfile) > 0: 3424 if len(self.pfile) > 0:
3340 if self.pfile.endswith(".e4p"): 3425 if self.pfile.endswith(".e4p"):
3341 self.pfile = self.pfile.replace(".e4p", ".epj") 3426 self.pfile = self.pfile.replace(".e4p", ".epj")
3351 3436
3352 def saveProjectAs(self): 3437 def saveProjectAs(self):
3353 """ 3438 """
3354 Public slot to save the current project to a different file. 3439 Public slot to save the current project to a different file.
3355 3440
3356 @return flag indicating success (boolean) 3441 @return flag indicating success
3442 @rtype bool
3357 """ 3443 """
3358 defaultFilter = self.tr("Project Files (*.epj)") 3444 defaultFilter = self.tr("Project Files (*.epj)")
3359 defaultPath = ( 3445 defaultPath = (
3360 self.ppath 3446 self.ppath
3361 if self.ppath 3447 if self.ppath
3411 3497
3412 def checkDirty(self): 3498 def checkDirty(self):
3413 """ 3499 """
3414 Public method to check dirty status and open a message window. 3500 Public method to check dirty status and open a message window.
3415 3501
3416 @return flag indicating whether this operation was successful (boolean) 3502 @return flag indicating whether this operation was successful
3503 @rtype bool
3417 """ 3504 """
3418 if self.isDirty(): 3505 if self.isDirty():
3419 res = EricMessageBox.okToClearData( 3506 res = EricMessageBox.okToClearData(
3420 self.parent(), 3507 self.parent(),
3421 self.tr("Close Project"), 3508 self.tr("Close Project"),
3555 def saveAllScripts(self, reportSyntaxErrors=False): 3642 def saveAllScripts(self, reportSyntaxErrors=False):
3556 """ 3643 """
3557 Public method to save all scripts belonging to the project. 3644 Public method to save all scripts belonging to the project.
3558 3645
3559 @param reportSyntaxErrors flag indicating special reporting 3646 @param reportSyntaxErrors flag indicating special reporting
3560 for syntax errors (boolean) 3647 for syntax errors
3561 @return flag indicating success (boolean) 3648 @type bool
3649 @return flag indicating success
3650 @rtype bool
3562 """ 3651 """
3563 vm = ericApp().getObject("ViewManager") 3652 vm = ericApp().getObject("ViewManager")
3564 success = True 3653 success = True
3565 filesWithSyntaxErrors = 0 3654 filesWithSyntaxErrors = 0
3566 for fn in vm.getOpenFilenames(): 3655 for fn in vm.getOpenFilenames():
3589 """ 3678 """
3590 Public method to check all scripts belonging to the project for 3679 Public method to check all scripts belonging to the project for
3591 their dirty status. 3680 their dirty status.
3592 3681
3593 @param reportSyntaxErrors flag indicating special reporting 3682 @param reportSyntaxErrors flag indicating special reporting
3594 for syntax errors (boolean) 3683 for syntax errors
3595 @return flag indicating success (boolean) 3684 @type bool
3685 @return flag indicating success
3686 @rtype bool
3596 """ 3687 """
3597 vm = ericApp().getObject("ViewManager") 3688 vm = ericApp().getObject("ViewManager")
3598 success = True 3689 success = True
3599 filesWithSyntaxErrors = 0 3690 filesWithSyntaxErrors = 0
3600 for fn in vm.getOpenFilenames(): 3691 for fn in vm.getOpenFilenames():
3672 3763
3673 def getProjectType(self): 3764 def getProjectType(self):
3674 """ 3765 """
3675 Public method to get the type of the project. 3766 Public method to get the type of the project.
3676 3767
3677 @return UI type of the project (string) 3768 @return UI type of the project
3769 @rtype str
3678 """ 3770 """
3679 return self.__pdata["PROJECTTYPE"] 3771 return self.__pdata["PROJECTTYPE"]
3680 3772
3681 def getProjectLanguage(self): 3773 def getProjectLanguage(self):
3682 """ 3774 """
3683 Public method to get the project's programming language. 3775 Public method to get the project's programming language.
3684 3776
3685 @return programming language (string) 3777 @return programming language
3778 @rtype str
3686 """ 3779 """
3687 return self.__pdata["PROGLANGUAGE"] 3780 return self.__pdata["PROGLANGUAGE"]
3688 3781
3689 def isMixedLanguageProject(self): 3782 def isMixedLanguageProject(self):
3690 """ 3783 """
3698 def isPythonProject(self): 3791 def isPythonProject(self):
3699 """ 3792 """
3700 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
3701 project. 3794 project.
3702 3795
3703 @return flag indicating a Python project (boolean) 3796 @return flag indicating a Python project
3797 @rtype bool
3704 """ 3798 """
3705 return self.__pdata["PROGLANGUAGE"] in ["Python3", "MicroPython"] 3799 return self.__pdata["PROGLANGUAGE"] in ["Python3", "MicroPython"]
3706 3800
3707 def isPy3Project(self): 3801 def isPy3Project(self):
3708 """ 3802 """
3709 Public method to check, if this project is a Python3 project. 3803 Public method to check, if this project is a Python3 project.
3710 3804
3711 @return flag indicating a Python3 project (boolean) 3805 @return flag indicating a Python3 project
3806 @rtype bool
3712 """ 3807 """
3713 return self.__pdata["PROGLANGUAGE"] == "Python3" 3808 return self.__pdata["PROGLANGUAGE"] == "Python3"
3714 3809
3715 def isMicroPythonProject(self): 3810 def isMicroPythonProject(self):
3716 """ 3811 """
3723 3818
3724 def isRubyProject(self): 3819 def isRubyProject(self):
3725 """ 3820 """
3726 Public method to check, if this project is a Ruby project. 3821 Public method to check, if this project is a Ruby project.
3727 3822
3728 @return flag indicating a Ruby project (boolean) 3823 @return flag indicating a Ruby project
3824 @rtype bool
3729 """ 3825 """
3730 return self.__pdata["PROGLANGUAGE"] == "Ruby" 3826 return self.__pdata["PROGLANGUAGE"] == "Ruby"
3731 3827
3732 def isJavaScriptProject(self): 3828 def isJavaScriptProject(self):
3733 """ 3829 """
3734 Public method to check, if this project is a JavaScript project. 3830 Public method to check, if this project is a JavaScript project.
3735 3831
3736 @return flag indicating a JavaScript project (boolean) 3832 @return flag indicating a JavaScript project
3833 @rtype bool
3737 """ 3834 """
3738 return self.__pdata["PROGLANGUAGE"] == "JavaScript" 3835 return self.__pdata["PROGLANGUAGE"] == "JavaScript"
3739 3836
3740 def getProjectSpellLanguage(self): 3837 def getProjectSpellLanguage(self):
3741 """ 3838 """
3742 Public method to get the project's programming language. 3839 Public method to get the project's programming language.
3743 3840
3744 @return programming language (string) 3841 @return programming language
3842 @rtype str
3745 """ 3843 """
3746 return self.__pdata["SPELLLANGUAGE"] 3844 return self.__pdata["SPELLLANGUAGE"]
3747 3845
3748 def getProjectDictionaries(self): 3846 def getProjectDictionaries(self):
3749 """ 3847 """
3750 Public method to get the names of the project specific dictionaries. 3848 Public method to get the names of the project specific dictionaries.
3751 3849
3752 @return tuple of two strings giving the absolute path names of the 3850 @return tuple containing the absolute path names of the project specific
3753 project specific word and exclude list 3851 word and exclude list
3852 @rtype tuple of (str, str)
3754 """ 3853 """
3755 pwl = "" 3854 pwl = ""
3756 if self.__pdata["SPELLWORDS"]: 3855 if self.__pdata["SPELLWORDS"]:
3757 pwl = os.path.join(self.ppath, self.__pdata["SPELLWORDS"]) 3856 pwl = os.path.join(self.ppath, self.__pdata["SPELLWORDS"])
3758 if not os.path.isfile(pwl): 3857 if not os.path.isfile(pwl):
3769 def getDefaultSourceExtension(self): 3868 def getDefaultSourceExtension(self):
3770 """ 3869 """
3771 Public method to get the default extension for the project's 3870 Public method to get the default extension for the project's
3772 programming language. 3871 programming language.
3773 3872
3774 @return default extension (including the dot) (string) 3873 @return default extension (including the dot)
3874 @rtype str
3775 """ 3875 """
3776 lang = self.__pdata["PROGLANGUAGE"] 3876 lang = self.__pdata["PROGLANGUAGE"]
3777 if lang in ("", "Python"): 3877 if lang in ("", "Python"):
3778 lang = "Python3" 3878 lang = "Python3"
3779 return self.__sourceExtensions(lang)[0] 3879 return self.__sourceExtensions(lang)[0]
3780 3880
3781 def getProjectPath(self): 3881 def getProjectPath(self):
3782 """ 3882 """
3783 Public method to get the project path. 3883 Public method to get the project path.
3784 3884
3785 @return project path (string) 3885 @return project path
3886 @rtype str
3786 """ 3887 """
3787 return self.ppath 3888 return self.ppath
3788 3889
3789 def startswithProjectPath(self, path): 3890 def startswithProjectPath(self, path):
3790 """ 3891 """
3808 3909
3809 def getProjectFile(self): 3910 def getProjectFile(self):
3810 """ 3911 """
3811 Public method to get the path of the project file. 3912 Public method to get the path of the project file.
3812 3913
3813 @return path of the project file (string) 3914 @return path of the project file
3915 @rtype str
3814 """ 3916 """
3815 return self.pfile 3917 return self.pfile
3816 3918
3817 def getProjectName(self): 3919 def getProjectName(self):
3818 """ 3920 """
3819 Public method to get the name of the project. 3921 Public method to get the name of the project.
3820 3922
3821 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.
3822 3924
3823 @return name of the project (string) 3925 @return name of the project
3926 @rtype str
3824 """ 3927 """
3825 if self.pfile: 3928 if self.pfile:
3826 name = os.path.splitext(self.pfile)[0] 3929 name = os.path.splitext(self.pfile)[0]
3827 return os.path.basename(name) 3930 return os.path.basename(name)
3828 else: 3931 else:
3830 3933
3831 def getProjectManagementDir(self): 3934 def getProjectManagementDir(self):
3832 """ 3935 """
3833 Public method to get the path of the management directory. 3936 Public method to get the path of the management directory.
3834 3937
3835 @return path of the management directory (string) 3938 @return path of the management directory
3939 @rtype str
3836 """ 3940 """
3837 return os.path.join(self.ppath, ".eric7project") 3941 return os.path.join(self.ppath, ".eric7project")
3838 3942
3839 def createProjectManagementDir(self): 3943 def createProjectManagementDir(self):
3840 """ 3944 """
3849 3953
3850 def getHash(self): 3954 def getHash(self):
3851 """ 3955 """
3852 Public method to get the project hash. 3956 Public method to get the project hash.
3853 3957
3854 @return project hash as a hex string (string) 3958 @return project hash as a hex string
3959 @rtype str
3855 """ 3960 """
3856 return self.__pdata["HASH"] 3961 return self.__pdata["HASH"]
3857 3962
3858 def getRelativePath(self, path): 3963 def getRelativePath(self, path):
3859 """ 3964 """
3860 Public method to convert a file path to a project relative 3965 Public method to convert a file path to a project relative
3861 file path. 3966 file path.
3862 3967
3863 @param path file or directory name to convert (string) 3968 @param path file or directory name to convert
3969 @type str
3864 @return project relative path or unchanged path, if path doesn't 3970 @return project relative path or unchanged path, if path doesn't
3865 belong to the project (string) 3971 belong to the project
3972 @rtype str
3866 """ 3973 """
3867 if path is None: 3974 if path is None:
3868 return "" 3975 return ""
3869 3976
3870 try: 3977 try:
3875 def getRelativeUniversalPath(self, path): 3982 def getRelativeUniversalPath(self, path):
3876 """ 3983 """
3877 Public method to convert a file path to a project relative 3984 Public method to convert a file path to a project relative
3878 file path with universal separators. 3985 file path with universal separators.
3879 3986
3880 @param path file or directory name to convert (string) 3987 @param path file or directory name to convert
3988 @type str
3881 @return project relative path or unchanged path, if path doesn't 3989 @return project relative path or unchanged path, if path doesn't
3882 belong to the project (string) 3990 belong to the project
3991 @rtype str
3883 """ 3992 """
3884 return FileSystemUtilities.fromNativeSeparators(self.getRelativePath(path)) 3993 return FileSystemUtilities.fromNativeSeparators(self.getRelativePath(path))
3885 3994
3886 def getAbsolutePath(self, fn): 3995 def getAbsolutePath(self, fn):
3887 """ 3996 """
3888 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
3889 file path. 3998 file path.
3890 3999
3891 @param fn file or directory name to convert (string) 4000 @param fn file or directory name to convert
3892 @return absolute path (string) 4001 @type str
4002 @return absolute path
4003 @rtype str
3893 """ 4004 """
3894 if not os.path.isabs(fn): 4005 if not os.path.isabs(fn):
3895 fn = os.path.join(self.ppath, fn) 4006 fn = os.path.join(self.ppath, fn)
3896 return fn 4007 return fn
3897 4008
3898 def getAbsoluteUniversalPath(self, fn): 4009 def getAbsoluteUniversalPath(self, fn):
3899 """ 4010 """
3900 Public method to convert a project relative file path with universal 4011 Public method to convert a project relative file path with universal
3901 separators to an absolute file path. 4012 separators to an absolute file path.
3902 4013
3903 @param fn file or directory name to convert (string) 4014 @param fn file or directory name to convert
3904 @return absolute path (string) 4015 @type str
4016 @return absolute path
4017 @rtype str
3905 """ 4018 """
3906 if not os.path.isabs(fn): 4019 if not os.path.isabs(fn):
3907 fn = os.path.join(self.ppath, FileSystemUtilities.toNativeSeparators(fn)) 4020 fn = os.path.join(self.ppath, FileSystemUtilities.toNativeSeparators(fn))
3908 return fn 4021 return fn
3909 4022
3910 def getEolString(self): 4023 def getEolString(self):
3911 """ 4024 """
3912 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.
3913 4026
3914 @return eol string (string) 4027 @return eol string
4028 @rtype str
3915 """ 4029 """
3916 if self.__pdata["EOL"] >= 0: 4030 if self.__pdata["EOL"] >= 0:
3917 return self.eols[self.__pdata["EOL"]] 4031 return self.eols[self.__pdata["EOL"]]
3918 else: 4032 else:
3919 eolMode = Preferences.getEditor("EOLMode") 4033 eolMode = Preferences.getEditor("EOLMode")
3929 4043
3930 def useSystemEol(self): 4044 def useSystemEol(self):
3931 """ 4045 """
3932 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.
3933 4047
3934 @return flag indicating the usage of system eol (boolean) 4048 @return flag indicating the usage of system eol
4049 @rtype bool
3935 """ 4050 """
3936 return self.__pdata["EOL"] == 0 4051 return self.__pdata["EOL"] == 0
3937 4052
3938 def getProjectVersion(self): 4053 def getProjectVersion(self):
3939 """ 4054 """
4101 def isProjectFile(self, fn): 4216 def isProjectFile(self, fn):
4102 """ 4217 """
4103 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
4104 project. 4219 project.
4105 4220
4106 @param fn filename to be checked (string) 4221 @param fn filename to be checked
4107 @return flag indicating membership (boolean) 4222 @type str
4223 @return flag indicating membership
4224 @rtype bool
4108 """ 4225 """
4109 return any( 4226 return any(
4110 self.__checkProjectFileGroup(fn, category) 4227 self.__checkProjectFileGroup(fn, category)
4111 for category in self.getFileCategories() 4228 for category in self.getFileCategories()
4112 ) 4229 )
4114 def __checkProjectFileGroup(self, fn, group): 4231 def __checkProjectFileGroup(self, fn, group):
4115 """ 4232 """
4116 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
4117 project. 4234 project.
4118 4235
4119 @param fn filename to be checked (string) 4236 @param fn filename to be checked
4120 @param group group to check (string) 4237 @type str
4121 @return flag indicating membership (boolean) 4238 @param group group to check
4239 @type str
4240 @return flag indicating membership
4241 @rtype bool
4122 """ 4242 """
4123 newfn = os.path.abspath(fn) 4243 newfn = os.path.abspath(fn)
4124 newfn = self.getRelativePath(newfn) 4244 newfn = self.getRelativePath(newfn)
4125 if newfn in self.__pdata[group] or ( 4245 if newfn in self.__pdata[group] or (
4126 group == "OTHERS" 4246 group == "OTHERS"
5414 """ 5534 """
5415 Public slot to initialize the project toolbar and the basic VCS 5535 Public slot to initialize the project toolbar and the basic VCS
5416 toolbar. 5536 toolbar.
5417 5537
5418 @param toolbarManager reference to a toolbar manager object 5538 @param toolbarManager reference to a toolbar manager object
5419 (EricToolBarManager) 5539 @type EricToolBarManager
5420 @return tuple of the generated toolbars (tuple of two QToolBar) 5540 @return tuple of the generated toolbars
5541 @rtype tuple of two QToolBar
5421 """ 5542 """
5422 from eric7 import VCS 5543 from eric7 import VCS
5423 5544
5424 tb = QToolBar(self.tr("Project"), self.ui) 5545 tb = QToolBar(self.tr("Project"), self.ui)
5425 tb.setObjectName("ProjectToolbar") 5546 tb.setObjectName("ProjectToolbar")
5489 def __openRecent(self, act): 5610 def __openRecent(self, act):
5490 """ 5611 """
5491 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
5492 projects. 5613 projects.
5493 5614
5494 @param act reference to the action that triggered (QAction) 5615 @param act reference to the action that triggered
5616 @type QAction
5495 """ 5617 """
5496 file = act.data() 5618 file = act.data()
5497 if file: 5619 if file:
5498 self.openProject(file) 5620 self.openProject(file)
5499 5621
5543 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
5544 include. If 'Automatic Inclusion' is enabled, the new files are 5666 include. If 'Automatic Inclusion' is enabled, the new files are
5545 automatically added to the project. 5667 automatically added to the project.
5546 5668
5547 @param AI flag indicating whether the automatic inclusion should 5669 @param AI flag indicating whether the automatic inclusion should
5548 be honoured (boolean) 5670 be honoured
5671 @type bool
5549 @param onUserDemand flag indicating whether this method was 5672 @param onUserDemand flag indicating whether this method was
5550 requested by the user via a menu action (boolean) 5673 requested by the user via a menu action
5674 @type bool
5551 """ 5675 """
5552 from .AddFoundFilesDialog import AddFoundFilesDialog 5676 from .AddFoundFilesDialog import AddFoundFilesDialog
5553 5677
5554 autoInclude = Preferences.getProject("AutoIncludeNewFiles") 5678 autoInclude = Preferences.getProject("AutoIncludeNewFiles")
5555 recursiveSearch = Preferences.getProject("SearchNewFilesRecursively") 5679 recursiveSearch = Preferences.getProject("SearchNewFilesRecursively")
5666 def othersAdded(self, fn, updateModel=True): 5790 def othersAdded(self, fn, updateModel=True):
5667 """ 5791 """
5668 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
5669 data area. 5793 data area.
5670 5794
5671 @param fn filename or directory name added (string) 5795 @param fn filename or directory name added
5796 @type str
5672 @param updateModel flag indicating an update of the model is requested 5797 @param updateModel flag indicating an update of the model is requested
5673 (boolean) 5798
5799 @type bool
5674 """ 5800 """
5675 self.projectFileAdded.emit(fn, "OTHERS") 5801 self.projectFileAdded.emit(fn, "OTHERS")
5676 updateModel and self.__model.addNewItem("OTHERS", fn) 5802 updateModel and self.__model.addNewItem("OTHERS", fn)
5677 5803
5678 def getActions(self): 5804 def getActions(self):
5679 """ 5805 """
5680 Public method to get a list of all actions. 5806 Public method to get a list of all actions.
5681 5807
5682 @return list of all actions (list of EricAction) 5808 @return list of all actions
5809 @rtype list of EricAction
5683 """ 5810 """
5684 return self.actions[:] 5811 return self.actions[:]
5685 5812
5686 def addEricActions(self, actions): 5813 def addEricActions(self, actions):
5687 """ 5814 """
5688 Public method to add actions to the list of actions. 5815 Public method to add actions to the list of actions.
5689 5816
5690 @param actions list of actions (list of EricAction) 5817 @param actions list of actions
5818 @type list of EricAction
5691 """ 5819 """
5692 self.actions.extend(actions) 5820 self.actions.extend(actions)
5693 5821
5694 def removeEricActions(self, actions): 5822 def removeEricActions(self, actions):
5695 """ 5823 """
5696 Public method to remove actions from the list of actions. 5824 Public method to remove actions from the list of actions.
5697 5825
5698 @param actions list of actions (list of EricAction) 5826 @param actions list of actions
5827 @type list of EricAction
5699 """ 5828 """
5700 for act in actions: 5829 for act in actions:
5701 with contextlib.suppress(ValueError): 5830 with contextlib.suppress(ValueError):
5702 self.actions.remove(act) 5831 self.actions.remove(act)
5703 5832
5704 def getMenu(self, menuName): 5833 def getMenu(self, menuName):
5705 """ 5834 """
5706 Public method to get a reference to the main menu or a submenu. 5835 Public method to get a reference to the main menu or a submenu.
5707 5836
5708 @param menuName name of the menu (string) 5837 @param menuName name of the menu
5709 @return reference to the requested menu (QMenu) or None 5838 @type str
5839 @return reference to the requested menu or None
5840 @rtype QMenu
5710 """ 5841 """
5711 try: 5842 try:
5712 return self.__menus[menuName] 5843 return self.__menus[menuName]
5713 except KeyError: 5844 except KeyError:
5714 return None 5845 return None
5715 5846
5716 def repopulateItem(self, fullname): 5847 def repopulateItem(self, fullname):
5717 """ 5848 """
5718 Public slot to repopulate a named item. 5849 Public slot to repopulate a named item.
5719 5850
5720 @param fullname full name of the item to repopulate (string) 5851 @param fullname full name of the item to repopulate
5852 @type str
5721 """ 5853 """
5722 if not self.isOpen(): 5854 if not self.isOpen():
5723 return 5855 return
5724 5856
5725 with EricOverrideCursor(): 5857 with EricOverrideCursor():
5734 5866
5735 def initVCS(self, vcsSystem=None, nooverride=False): 5867 def initVCS(self, vcsSystem=None, nooverride=False):
5736 """ 5868 """
5737 Public method used to instantiate a vcs system. 5869 Public method used to instantiate a vcs system.
5738 5870
5739 @param vcsSystem type of VCS to be used (string) 5871 @param vcsSystem type of VCS to be used
5872 @type str
5740 @param nooverride flag indicating to ignore an override request 5873 @param nooverride flag indicating to ignore an override request
5741 (boolean) 5874
5875 @type bool
5742 @return a reference to the vcs object 5876 @return a reference to the vcs object
5877 @rtype VersionControl
5743 """ 5878 """
5744 from eric7 import VCS 5879 from eric7 import VCS
5745 5880
5746 vcs = None 5881 vcs = None
5747 forProject = True 5882 forProject = True
5850 def vcsSoftwareAvailable(self): 5985 def vcsSoftwareAvailable(self):
5851 """ 5986 """
5852 Public method to check, if some supported VCS software is available 5987 Public method to check, if some supported VCS software is available
5853 to the IDE. 5988 to the IDE.
5854 5989
5855 @return flag indicating availability of VCS software (boolean) 5990 @return flag indicating availability of VCS software
5991 @rtype bool
5856 """ 5992 """
5857 vcsSystemsDict = ( 5993 vcsSystemsDict = (
5858 ericApp() 5994 ericApp()
5859 .getObject("PluginManager") 5995 .getObject("PluginManager")
5860 .getPluginDisplayStrings("version_control") 5996 .getPluginDisplayStrings("version_control")
6080 6216
6081 def setStatusMonitorInterval(self, interval): 6217 def setStatusMonitorInterval(self, interval):
6082 """ 6218 """
6083 Public method to se the interval of the VCS status monitor thread. 6219 Public method to se the interval of the VCS status monitor thread.
6084 6220
6085 @param interval status monitor interval in seconds (integer) 6221 @param interval status monitor interval in seconds
6222 @type int
6086 """ 6223 """
6087 if self.vcs is not None: 6224 if self.vcs is not None:
6088 self.vcs.setStatusMonitorInterval(interval, self) 6225 self.vcs.setStatusMonitorInterval(interval, self)
6089 6226
6090 def getStatusMonitorInterval(self): 6227 def getStatusMonitorInterval(self):
6091 """ 6228 """
6092 Public method to get the monitor interval. 6229 Public method to get the monitor interval.
6093 6230
6094 @return interval in seconds (integer) 6231 @return interval in seconds
6232 @rtype int
6095 """ 6233 """
6096 if self.vcs is not None: 6234 if self.vcs is not None:
6097 return self.vcs.getStatusMonitorInterval() 6235 return self.vcs.getStatusMonitorInterval()
6098 else: 6236 else:
6099 return 0 6237 return 0
6100 6238
6101 def setStatusMonitorAutoUpdate(self, auto): 6239 def setStatusMonitorAutoUpdate(self, auto):
6102 """ 6240 """
6103 Public method to enable the auto update function. 6241 Public method to enable the auto update function.
6104 6242
6105 @param auto status of the auto update function (boolean) 6243 @param auto status of the auto update function
6244 @type bool
6106 """ 6245 """
6107 if self.vcs is not None: 6246 if self.vcs is not None:
6108 self.vcs.setStatusMonitorAutoUpdate(auto) 6247 self.vcs.setStatusMonitorAutoUpdate(auto)
6109 6248
6110 def getStatusMonitorAutoUpdate(self): 6249 def getStatusMonitorAutoUpdate(self):
6111 """ 6250 """
6112 Public method to retrieve the status of the auto update function. 6251 Public method to retrieve the status of the auto update function.
6113 6252
6114 @return status of the auto update function (boolean) 6253 @return status of the auto update function
6254 @rtype bool
6115 """ 6255 """
6116 if self.vcs is not None: 6256 if self.vcs is not None:
6117 return self.vcs.getStatusMonitorAutoUpdate() 6257 return self.vcs.getStatusMonitorAutoUpdate()
6118 else: 6258 else:
6119 return False 6259 return False
6127 6267
6128 def clearStatusMonitorCachedState(self, name): 6268 def clearStatusMonitorCachedState(self, name):
6129 """ 6269 """
6130 Public method to clear the cached VCS state of a file/directory. 6270 Public method to clear the cached VCS state of a file/directory.
6131 6271
6132 @param name name of the entry to be cleared (string) 6272 @param name name of the entry to be cleared
6273 @type str
6133 """ 6274 """
6134 if self.vcs is not None: 6275 if self.vcs is not None:
6135 self.vcs.clearStatusMonitorCachedState(name) 6276 self.vcs.clearStatusMonitorCachedState(name)
6136 6277
6137 def startStatusMonitor(self): 6278 def startStatusMonitor(self):
6229 @pyqtSlot() 6370 @pyqtSlot()
6230 def __pluginCreateArchives(self, snapshot=False): 6371 def __pluginCreateArchives(self, snapshot=False):
6231 """ 6372 """
6232 Private slot to create eric plugin archives. 6373 Private slot to create eric plugin archives.
6233 6374
6234 @param snapshot flag indicating snapshot archives (boolean) 6375 @param snapshot flag indicating snapshot archives
6376 @type bool
6235 """ 6377 """
6236 if not self.__pdata["MAINSCRIPT"]: 6378 if not self.__pdata["MAINSCRIPT"]:
6237 EricMessageBox.critical( 6379 EricMessageBox.critical(
6238 self.ui, 6380 self.ui,
6239 self.tr("Create Plugin Archive"), 6381 self.tr("Create Plugin Archive"),
6431 6573
6432 def __createZipDirEntries(self, path, zipFile): 6574 def __createZipDirEntries(self, path, zipFile):
6433 """ 6575 """
6434 Private method to create dir entries in the zip file. 6576 Private method to create dir entries in the zip file.
6435 6577
6436 @param path name of the directory entry to create (string) 6578 @param path name of the directory entry to create
6437 @param zipFile open ZipFile object (zipfile.ZipFile) 6579 @type str
6580 @param zipFile open ZipFile object
6581 @type zipfile.ZipFile
6438 """ 6582 """
6439 if path in ("", "/", "\\"): 6583 if path in ("", "/", "\\"):
6440 return 6584 return
6441 6585
6442 if not path.endswith("/") and not path.endswith("\\"): 6586 if not path.endswith("/") and not path.endswith("\\"):
6452 6596
6453 The version entry in the plugin module is modified to signify 6597 The version entry in the plugin module is modified to signify
6454 a snapshot version. This method appends the string "-snapshot-" 6598 a snapshot version. This method appends the string "-snapshot-"
6455 and date indicator to the version string. 6599 and date indicator to the version string.
6456 6600
6457 @param filename name of the plugin file to modify (string) 6601 @param filename name of the plugin file to modify
6458 @return modified source (bytes), snapshot version string (string) 6602 @type str
6603 @return modified source (bytes), snapshot version string
6604 @rtype str
6459 """ 6605 """
6460 try: 6606 try:
6461 sourcelines, encoding = Utilities.readEncodedFile(filename) 6607 sourcelines, encoding = Utilities.readEncodedFile(filename)
6462 sourcelines = sourcelines.splitlines(True) 6608 sourcelines = sourcelines.splitlines(True)
6463 except (OSError, UnicodeError) as why: 6609 except (OSError, UnicodeError) as why:
6493 6639
6494 def __pluginExtractVersion(self, filename): 6640 def __pluginExtractVersion(self, filename):
6495 """ 6641 """
6496 Private method to extract the version number entry. 6642 Private method to extract the version number entry.
6497 6643
6498 @param filename name of the plugin file (string) 6644 @param filename name of the plugin file
6499 @return version string (string) 6645 @type str
6646 @return version string
6647 @rtype str
6500 """ 6648 """
6501 version = "0.0.0" 6649 version = "0.0.0"
6502 try: 6650 try:
6503 sourcelines = Utilities.readEncodedFile(filename)[0] 6651 sourcelines = Utilities.readEncodedFile(filename)[0]
6504 sourcelines = sourcelines.splitlines(True) 6652 sourcelines = sourcelines.splitlines(True)

eric ide

mercurial