--- a/src/eric7/Graphics/ImportsDiagramBuilder.py Sat Feb 17 19:46:33 2024 +0100 +++ b/src/eric7/Graphics/ImportsDiagramBuilder.py Sun Feb 18 12:23:14 2024 +0100 @@ -14,6 +14,7 @@ from PyQt6.QtWidgets import QApplication, QGraphicsTextItem from eric7 import Globals, Preferences +from eric7.EricWidgets.EricApplication import ericApp from eric7.EricWidgets.EricProgressDialog import EricProgressDialog from eric7.SystemUtilities import FileSystemUtilities @@ -49,7 +50,10 @@ self.setObjectName("ImportsDiagram") self.showExternalImports = showExternalImports - self.packagePath = os.path.abspath(package) + if FileSystemUtilities.isRemoteFileName(package): + self.packagePath = package + else: + self.packagePath = os.path.abspath(package) self.__relPackagePath = ( self.project.getRelativePath(self.packagePath) @@ -57,16 +61,35 @@ else "" ) + self.__remotefsInterface = ( + ericApp().getObject("EricServer").getServiceInterface("FileSystem") + ) + def initialize(self): """ Public method to initialize the object. """ - self.package = os.path.splitdrive(self.packagePath)[1].replace(os.sep, ".")[1:] hasInit = True ppath = self.packagePath - while hasInit: - ppath = os.path.dirname(ppath) - hasInit = len(glob.glob(os.path.join(ppath, "__init__.*"))) > 0 + + if FileSystemUtilities.isRemoteFileName(self.packagePath): + self.package = ( + FileSystemUtilities.plainFileName(self.packagePath)[1:] + .replace("/", ".") + .replace("\\", ".") + ) + while hasInit: + ppath = self.__remotefsInterface.dirname(ppath) + globPattern = self.__remotefsInterface.join(ppath, "__init__.*") + hasInit = len(self.__remotefsInterface.glob(globPattern)) > 0 + else: + self.package = ( + os.path.splitdrive(self.packagePath)[1][1:].replace(os.sep, ".") + ) + while hasInit: + ppath = os.path.dirname(ppath) + hasInit = len(glob.glob(os.path.join(ppath, "__init__.*"))) > 0 + self.shortPackage = self.packagePath.replace(ppath, "").replace(os.sep, ".")[1:] pname = self.project.getProjectName() @@ -93,13 +116,21 @@ moduleDict = {} modules = [] for ext in Preferences.getPython("Python3Extensions"): - modules.extend( - glob.glob( - FileSystemUtilities.normjoinpath( - self.packagePath, "*{0}".format(ext) + if FileSystemUtilities.isRemoteFileName(self.packagePath): + modules.extend( + [ + FileSystemUtilities.remoteFileName(f) + for f in self.__remotefsInterface.glob( + self.__remotefsInterface.join(self.packagePath, f"*{ext}") + ) + ] + ) + else: + modules.extend( + glob.glob( + FileSystemUtilities.normjoinpath(self.packagePath, f"*{ext}") ) ) - ) tot = len(modules) progress = EricProgressDialog( @@ -141,7 +172,11 @@ """ Public method to build the modules shapes of the diagram. """ - initlist = glob.glob(os.path.join(self.packagePath, "__init__.*")) + if FileSystemUtilities.isRemoteFileName(self.packagePath): + globPattern = self.__remotefsInterface.join(self.packagePath, "__init__.*") + initlist = self.__remotefsInterface.glob(globPattern) + else: + initlist = glob.glob(os.path.join(self.packagePath, "__init__.*")) if len(initlist) == 0: ct = QGraphicsTextItem(None) ct.setHtml(