UI/BrowserModel.py

changeset 788
5b1b59777460
parent 608
d8fea1e76975
child 791
9ec2ac20e54e
equal deleted inserted replaced
786:06290d4db8ab 788:5b1b59777460
523 moduleName = parentItem.moduleName() 523 moduleName = parentItem.moduleName()
524 fileName = parentItem.fileName() 524 fileName = parentItem.fileName()
525 try: 525 try:
526 dict = Utilities.ClassBrowsers.readmodule( 526 dict = Utilities.ClassBrowsers.readmodule(
527 moduleName, [parentItem.dirName()], 527 moduleName, [parentItem.dirName()],
528 parentItem.isPythonFile() or parentItem.isPython3File()) 528 parentItem.isPython2File() or parentItem.isPython3File())
529 except ImportError: 529 except ImportError:
530 return 530 return
531 531
532 keys = list(dict.keys()) 532 keys = list(dict.keys())
533 if len(keys) > 0: 533 if len(keys) > 0:
948 self.sourceLanguage = sourceLanguage 948 self.sourceLanguage = sourceLanguage
949 949
950 self._moduleName = '' 950 self._moduleName = ''
951 951
952 pixName = "" 952 pixName = ""
953 if self.isPythonFile(): 953 if self.isPython2File():
954 if self.fileext == '.py': 954 if self.fileext == '.py':
955 pixName = "filePython.png" 955 pixName = "filePython.png"
956 else: 956 else:
957 pixName = "filePython2.png" 957 pixName = "filePython2.png"
958 self._populated = False 958 self._populated = False
1008 @param finfo the string for the file (string) 1008 @param finfo the string for the file (string)
1009 @param full flag indicating full pathname should be displayed (boolean) 1009 @param full flag indicating full pathname should be displayed (boolean)
1010 """ 1010 """
1011 self._filename = os.path.abspath(finfo) 1011 self._filename = os.path.abspath(finfo)
1012 self.itemData[0] = os.path.basename(finfo) 1012 self.itemData[0] = os.path.basename(finfo)
1013 if self.isPythonFile() or self.isPython3File() or \ 1013 if self.isPython2File() or self.isPython3File() or \
1014 self.isRubyFile() or self.isIdlFile(): 1014 self.isRubyFile() or self.isIdlFile():
1015 self._dirName = os.path.dirname(finfo) 1015 self._dirName = os.path.dirname(finfo)
1016 self._moduleName = os.path.basename(finfo) 1016 self._moduleName = os.path.basename(finfo)
1017 1017
1018 def fileName(self): 1018 def fileName(self):
1053 1053
1054 @return module name (string) 1054 @return module name (string)
1055 """ 1055 """
1056 return self._moduleName 1056 return self._moduleName
1057 1057
1058 def isPythonFile(self): 1058 def isPython2File(self):
1059 """ 1059 """
1060 Public method to check, if this file is a Python script. 1060 Public method to check, if this file is a Python script.
1061 1061
1062 @return flag indicating a Python file (boolean) 1062 @return flag indicating a Python file (boolean)
1063 """ 1063 """
1064 return self.fileext in Preferences.getPython("PythonExtensions") or \ 1064 return self.fileext in Preferences.getPython("PythonExtensions") or \
1065 (self.fileext == "" and self.sourceLanguage == "Python") 1065 (self.fileext == "" and self.sourceLanguage in ["Python", "Python2"])
1066 1066
1067 def isPython3File(self): 1067 def isPython3File(self):
1068 """ 1068 """
1069 Public method to check, if this file is a Python3 script. 1069 Public method to check, if this file is a Python3 script.
1070 1070

eric ide

mercurial