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"]: |
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: |
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 """ |
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 |
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) |
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 = [ |
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) |
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"), |
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: |
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(): |
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: |
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") |
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" |
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") |
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") |
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 |
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 |
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: |
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 |