src/eric7/UI/BrowserModel.py

branch
server
changeset 10610
bb0149571d94
parent 10604
0f4017309f35
child 10651
280a53840aa3
equal deleted inserted replaced
10605:b6f5e27daeb5 10610:bb0149571d94
747 @param repopulate flag indicating a repopulation 747 @param repopulate flag indicating a repopulation
748 @type bool 748 @type bool
749 """ 749 """
750 from eric7.Utilities import ClassBrowsers 750 from eric7.Utilities import ClassBrowsers
751 751
752 # TODO: add support for 'remote:' directories
753 moduleName = parentItem.moduleName() 752 moduleName = parentItem.moduleName()
754 fileName = parentItem.fileName() 753 fileName = parentItem.fileName()
755 try: 754 try:
756 dictionary = ClassBrowsers.readmodule( 755 dictionary = ClassBrowsers.readmodule(
757 moduleName, 756 moduleName,
1208 class BrowserSimpleDirectoryItem(BrowserItem): 1207 class BrowserSimpleDirectoryItem(BrowserItem):
1209 """ 1208 """
1210 Class implementing the data structure for browser simple directory items. 1209 Class implementing the data structure for browser simple directory items.
1211 """ 1210 """
1212 1211
1213 # TODO: add support for 'remote:' directories 1212 def __init__(self, parent, text, path="", fsInterface=None):
1214 def __init__(self, parent, text, path=""):
1215 """ 1213 """
1216 Constructor 1214 Constructor
1217 1215
1218 @param parent parent item 1216 @param parent parent item
1219 @type BrowserItem 1217 @type BrowserItem
1220 @param text text to be displayed 1218 @param text text to be displayed
1221 @type str 1219 @type str
1222 @param path path of the directory 1220 @param path path of the directory
1223 @type str 1221 @type str
1222 @param fsInterface reference to the 'eric-ide' server file system interface
1223 (defaults to None)
1224 @type EricServerFileSystemInterface (optional)
1224 """ 1225 """
1225 BrowserItem.__init__(self, parent, text) 1226 BrowserItem.__init__(self, parent, text)
1226 1227
1228 self.__fsInterface = fsInterface
1229
1227 self.type_ = BrowserItemType.SimpleDirectory 1230 self.type_ = BrowserItemType.SimpleDirectory
1228 1231
1229 self._dirName = path 1232 self._dirName = path
1230 if not os.path.isdir(self._dirName): 1233 if FileSystemUtilities.isRemoteFileName(self._dirName):
1231 self._dirName = os.path.dirname(self._dirName) 1234 if not self.__fsInterface.isdir(self._dirName):
1232 1235 self._dirName = self.__fsInterface.dirname(self._dirName)
1233 if os.path.lexists(self._dirName) and os.path.islink(self._dirName): 1236 else:
1237 if not os.path.isdir(self._dirName):
1238 self._dirName = os.path.dirname(self._dirName)
1239
1240 if (
1241 FileSystemUtilities.isPlainFileName(self._dirName)
1242 and os.path.lexists(self._dirName)
1243 and os.path.islink(self._dirName)
1244 ):
1234 self.symlink = True 1245 self.symlink = True
1235 self.icon = EricPixmapCache.getSymlinkIcon("dirClosed") 1246 self.icon = EricPixmapCache.getSymlinkIcon("dirClosed")
1236 else: 1247 else:
1237 self.icon = EricPixmapCache.getIcon("dirClosed") 1248 self.icon = EricPixmapCache.getIcon("dirClosed")
1238 1249
1243 @param dinfo dinfo is the string for the directory 1254 @param dinfo dinfo is the string for the directory
1244 @type str 1255 @type str
1245 @param full flag indicating full path name should be displayed 1256 @param full flag indicating full path name should be displayed
1246 @type bool 1257 @type bool
1247 """ 1258 """
1248 # TODO: add support for 'remote:' directories 1259 if FileSystemUtilities.isRemoteFileName(dinfo):
1249 self._dirName = os.path.abspath(dinfo) 1260 self._dirName = dinfo
1250 self.itemData[0] = os.path.basename(self._dirName) 1261 self.itemData[0] = self.__fsInterface.basename(self._dirName)
1262 else:
1263 self._dirName = os.path.abspath(dinfo)
1264 self.itemData[0] = os.path.basename(self._dirName)
1251 1265
1252 def dirName(self): 1266 def dirName(self):
1253 """ 1267 """
1254 Public method returning the directory name. 1268 Public method returning the directory name.
1255 1269
1416 @rtype str 1430 @rtype str
1417 """ 1431 """
1418 return "sys.path" 1432 return "sys.path"
1419 1433
1420 1434
1421 # TODO: add support for 'remote:' directories
1422 class BrowserFileItem(BrowserItem): 1435 class BrowserFileItem(BrowserItem):
1423 """ 1436 """
1424 Class implementing the data structure for browser file items. 1437 Class implementing the data structure for browser file items.
1425 """ 1438 """
1426 1439

eric ide

mercurial