src/eric7/Project/Project.py

branch
eric7
changeset 10373
093dcebe5ecb
parent 10321
4a017fdf316f
child 10384
5d02b2c6faaa
equal deleted inserted replaced
10372:1444b4bee64b 10373:093dcebe5ecb
708 Public method to get the list of known file categories. 708 Public method to get the list of known file categories.
709 709
710 @return list of known file categories 710 @return list of known file categories
711 @rtype list of str 711 @rtype list of str
712 """ 712 """
713 return list(self.__fileCategoriesRepository.keys()) 713 return list(self.__fileCategoriesRepository)
714 714
715 def getFileCategoryFilters(self, categories=None, withOthers=False, withAll=True): 715 def getFileCategoryFilters(self, categories=None, withOthers=False, withAll=True):
716 """ 716 """
717 Public method to get a list of file selection filters for the given categories. 717 Public method to get a list of file selection filters for the given categories.
718 718
908 fileTypesDict["*.qm"] = "TRANSLATIONS" 908 fileTypesDict["*.qm"] = "TRANSLATIONS"
909 909
910 # File categories handled by activated plugin project browsers 910 # File categories handled by activated plugin project browsers
911 for fileCategory in [ 911 for fileCategory in [
912 f 912 f
913 for f in self.__fileCategoriesRepository.keys() 913 for f in self.__fileCategoriesRepository
914 if f not in ["SOURCES", "FORMS", "RESOURCES", "TRANSLATIONS", "OTHERS"] 914 if f not in ["SOURCES", "FORMS", "RESOURCES", "TRANSLATIONS", "OTHERS"]
915 ]: 915 ]:
916 for ext in self.__fileCategoriesRepository[ 916 for ext in self.__fileCategoriesRepository[
917 fileCategory.upper() 917 fileCategory.upper()
918 ].fileCategoryExtensions: 918 ].fileCategoryExtensions:
946 if "*.qm" not in self.__pdata["FILETYPES"]: 946 if "*.qm" not in self.__pdata["FILETYPES"]:
947 self.__pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" 947 self.__pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS"
948 with contextlib.suppress(KeyError): 948 with contextlib.suppress(KeyError):
949 if self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]] is not None: 949 if self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]] is not None:
950 ftypes = self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]]() 950 ftypes = self.__fileTypeCallbacks[self.__pdata["PROJECTTYPE"]]()
951 for pattern, ftype in list(ftypes.items()): 951 for pattern, ftype in ftypes.items():
952 if pattern not in self.__pdata["FILETYPES"]: 952 if pattern not in self.__pdata["FILETYPES"]:
953 self.__pdata["FILETYPES"][pattern] = ftype 953 self.__pdata["FILETYPES"][pattern] = ftype
954 self.setDirty(True) 954 self.setDirty(True)
955 955
956 def __loadRecent(self): 956 def __loadRecent(self):
1870 filetype = "OTHERS" 1870 filetype = "OTHERS"
1871 bfn = os.path.basename(newfn) 1871 bfn = os.path.basename(newfn)
1872 if fnmatch.fnmatch(bfn, "*.ts") or fnmatch.fnmatch(bfn, "*.qm"): 1872 if fnmatch.fnmatch(bfn, "*.ts") or fnmatch.fnmatch(bfn, "*.qm"):
1873 filetype = "TRANSLATIONS" 1873 filetype = "TRANSLATIONS"
1874 else: 1874 else:
1875 for pattern in sorted(self.__pdata["FILETYPES"].keys(), reverse=True): 1875 for pattern in sorted(self.__pdata["FILETYPES"], reverse=True):
1876 if fnmatch.fnmatch(bfn, pattern): 1876 if fnmatch.fnmatch(bfn, pattern):
1877 filetype = self.__pdata["FILETYPES"][pattern] 1877 filetype = self.__pdata["FILETYPES"][pattern]
1878 break 1878 break
1879 1879
1880 if filetype == "__IGNORE__": 1880 if filetype == "__IGNORE__":
1986 @param quiet flag indicating quiet operations (boolean) 1986 @param quiet flag indicating quiet operations (boolean)
1987 """ 1987 """
1988 # get all relevant filename patterns 1988 # get all relevant filename patterns
1989 patterns = [] 1989 patterns = []
1990 ignorePatterns = [] 1990 ignorePatterns = []
1991 for pattern, patterntype in list(self.__pdata["FILETYPES"].items()): 1991 for pattern, patterntype in self.__pdata["FILETYPES"].items():
1992 if patterntype == filetype: 1992 if patterntype == filetype:
1993 patterns.append(pattern) 1993 patterns.append(pattern)
1994 elif patterntype == "__IGNORE__": 1994 elif patterntype == "__IGNORE__":
1995 ignorePatterns.append(pattern) 1995 ignorePatterns.append(pattern)
1996 1996
2281 # iterate over all files checking for a reassignment 2281 # iterate over all files checking for a reassignment
2282 for fileCategory in self.getFileCategories(): 2282 for fileCategory in self.getFileCategories():
2283 for fn in self.__pdata[fileCategory][:]: 2283 for fn in self.__pdata[fileCategory][:]:
2284 filetype = fileCategory 2284 filetype = fileCategory
2285 bfn = os.path.basename(fn) 2285 bfn = os.path.basename(fn)
2286 for pattern in sorted(self.__pdata["FILETYPES"].keys(), reverse=True): 2286 for pattern in sorted(self.__pdata["FILETYPES"], reverse=True):
2287 if fnmatch.fnmatch(bfn, pattern): 2287 if fnmatch.fnmatch(bfn, pattern):
2288 filetype = self.__pdata["FILETYPES"][pattern] 2288 filetype = self.__pdata["FILETYPES"][pattern]
2289 break 2289 break
2290 2290
2291 if filetype != "__IGNORE__": 2291 if filetype != "__IGNORE__":
2774 ericApp() 2774 ericApp()
2775 .getObject("PluginManager") 2775 .getObject("PluginManager")
2776 .getPluginDisplayStrings("version_control") 2776 .getPluginDisplayStrings("version_control")
2777 ) 2777 )
2778 vcsSystemsDisplay = [self.tr("None")] 2778 vcsSystemsDisplay = [self.tr("None")]
2779 keys = sorted(vcsSystemsDict.keys()) 2779 for key in sorted(vcsSystemsDict):
2780 for key in keys:
2781 vcsSystemsDisplay.append(vcsSystemsDict[key]) 2780 vcsSystemsDisplay.append(vcsSystemsDict[key])
2782 vcsSelected, ok = QInputDialog.getItem( 2781 vcsSelected, ok = QInputDialog.getItem(
2783 None, 2782 None,
2784 self.tr("New Project"), 2783 self.tr("New Project"),
2785 self.tr("Select version control system for the project"), 2784 self.tr("Select version control system for the project"),
2868 if environmentPath: 2867 if environmentPath:
2869 # there is already an embeded venv; ignore thie whenn adding files 2868 # there is already an embeded venv; ignore thie whenn adding files
2870 ignoreList = [os.path.split(environmentPath)[-1]] 2869 ignoreList = [os.path.split(environmentPath)[-1]]
2871 with EricOverrideCursor(): 2870 with EricOverrideCursor():
2872 # search the project directory for files with known extensions 2871 # search the project directory for files with known extensions
2873 filespecs = list(self.__pdata["FILETYPES"].keys()) 2872 for filespec in self.__pdata["FILETYPES"]:
2874 for filespec in filespecs:
2875 files = FileSystemUtilities.direntries( 2873 files = FileSystemUtilities.direntries(
2876 self.ppath, 2874 self.ppath,
2877 filesonly=True, 2875 filesonly=True,
2878 pattern=filespec, 2876 pattern=filespec,
2879 ignore=ignoreList, 2877 ignore=ignoreList,
3120 @param filename filename used to determine the associated lexer 3118 @param filename filename used to determine the associated lexer
3121 language (string) 3119 language (string)
3122 @return the requested lexer language (string) 3120 @return the requested lexer language (string)
3123 """ 3121 """
3124 # try user settings first 3122 # try user settings first
3125 for pattern, language in list(self.__pdata["LEXERASSOCS"].items()): 3123 for pattern, language in self.__pdata["LEXERASSOCS"].items():
3126 if fnmatch.fnmatch(filename, pattern): 3124 if fnmatch.fnmatch(filename, pattern):
3127 return language 3125 return language
3128 3126
3129 # try project type specific defaults next 3127 # try project type specific defaults next
3130 projectType = self.__pdata["PROJECTTYPE"] 3128 projectType = self.__pdata["PROJECTTYPE"]
5610 dirs.append(d) 5608 dirs.append(d)
5611 continue 5609 continue
5612 5610
5613 filetype = "" 5611 filetype = ""
5614 bfn = os.path.basename(fn) 5612 bfn = os.path.basename(fn)
5615 for pattern in sorted(self.__pdata["FILETYPES"].keys(), reverse=True): 5613 for pattern in sorted(self.__pdata["FILETYPES"], reverse=True):
5616 if fnmatch.fnmatch(bfn, pattern): 5614 if fnmatch.fnmatch(bfn, pattern):
5617 filetype = self.__pdata["FILETYPES"][pattern] 5615 filetype = self.__pdata["FILETYPES"][pattern]
5618 break 5616 break
5619 5617
5620 if ( 5618 if (

eric ide

mercurial