--- a/src/eric7/Graphics/ApplicationDiagramBuilder.py Sun Feb 18 17:31:14 2024 +0100 +++ b/src/eric7/Graphics/ApplicationDiagramBuilder.py Sun Feb 18 17:31:34 2024 +0100 @@ -15,6 +15,7 @@ from eric7 import Globals, Preferences from eric7.EricWidgets import EricMessageBox +from eric7.EricWidgets.EricApplication import ericApp from eric7.EricWidgets.EricProgressDialog import EricProgressDialog from eric7.SystemUtilities import FileSystemUtilities @@ -49,6 +50,10 @@ self.tr("Application Diagram {0}").format(self.project.getProjectName()) ) + self.__remotefsInterface = ( + ericApp().getObject("EricServer").getServiceInterface("FileSystem") + ) + def __buildModulesDict(self): """ Private method to build a dictionary of modules contained in the @@ -64,9 +69,16 @@ mods = self.project.getProjectData(dataKey="SOURCES") modules = [] for module in mods: - modules.append( - FileSystemUtilities.normabsjoinpath(self.project.ppath, module) - ) + if FileSystemUtilities.isRemoteFileName(self.project.getProjectPath()): + modules.append( + self.__remotefsInterface.join(self.project.getProjectPath(), module) + ) + else: + modules.append( + FileSystemUtilities.normabsjoinpath( + self.project.getProjectPath(), module + ) + ) tot = len(modules) progress = EricProgressDialog( self.tr("Parsing modules..."), @@ -111,26 +123,48 @@ @rtype str """ candidates = [] - path = self.project.getProjectPath() - init = os.path.join(path, "__init__.py") - if os.path.exists(init): - # project is a package - return path + ppath = self.project.getProjectPath() + + if FileSystemUtilities.isRemoteFileName(ppath): + init = self.__remotefsInterface.join(ppath, "__init__.py") + if self.__remotefsInterface.exists(init): + # remote project is a package + return ppath + else: + # check, if any of the top directories is a package + for entry in self.__remotefsInterface.listdir(ppath)[2]: + if ( + not entry["name"].startswith(".") + and entry["is_dir"] + and self.__remotefsInterface.exists( + self.__remotefsInterface.join(entry["path"], "__init__.py") + ) + ): + candidates.append(entry["path"]) + + # check, if project uses the 'src' layout + srcPath = self.__remotefsInterface.join(ppath, "src") + if self.__remotefsInterface.exists(srcPath): + for entry in self.__remotefsInterface.listdir(srcPath)[2]: + if ( + not entry["name"].startswith(".") + and entry["is_dir"] + and self.__remotefsInterface.exists( + self.__remotefsInterface.join( + entry["path"], "__init__.py" + ) + ) + ): + candidates.append(entry["path"]) + else: - # check, if any of the top directories is a package - with os.scandir(path) as dirEntriesIterator: - for entry in [ - e for e in dirEntriesIterator if not e.name.startswith(".") - ]: - if entry.is_dir() and os.path.exists( - os.path.join(entry.path, "__init__.py") - ): - candidates.append(entry.path) - - # check, if project uses the 'src' layout - srcPath = os.path.join(path, "src") - if os.path.exists(srcPath): - with os.scandir(srcPath) as dirEntriesIterator: + init = os.path.join(ppath, "__init__.py") + if os.path.exists(init): + # project is a package + return ppath + else: + # check, if any of the top directories is a package + with os.scandir(ppath) as dirEntriesIterator: for entry in [ e for e in dirEntriesIterator if not e.name.startswith(".") ]: @@ -139,6 +173,18 @@ ): candidates.append(entry.path) + # check, if project uses the 'src' layout + srcPath = os.path.join(ppath, "src") + if os.path.exists(srcPath): + with os.scandir(srcPath) as dirEntriesIterator: + for entry in [ + e for e in dirEntriesIterator if not e.name.startswith(".") + ]: + if entry.is_dir() and os.path.exists( + os.path.join(entry.path, "__init__.py") + ): + candidates.append(entry.path) + if len(candidates) == 1: return candidates[0] elif len(candidates) > 1: @@ -172,7 +218,12 @@ # no root path detected return - root = os.path.splitdrive(rpath)[1].replace(os.sep, ".")[1:] + if FileSystemUtilities.isRemoteFileName(rpath): + root = self.__remotefsInterface.splitdrive(rpath)[1][1:].replace( + self.__remotefsInterface.separator(), "." + ) + else: + root = os.path.splitdrive(rpath)[1][1:].replace(os.sep, ".") packages = {} self.__shapes = {}