12 import time |
12 import time |
13 |
13 |
14 from PyQt6.QtWidgets import QApplication, QGraphicsTextItem |
14 from PyQt6.QtWidgets import QApplication, QGraphicsTextItem |
15 |
15 |
16 from eric7 import Globals, Preferences |
16 from eric7 import Globals, Preferences |
|
17 from eric7.EricWidgets.EricApplication import ericApp |
17 from eric7.EricWidgets.EricProgressDialog import EricProgressDialog |
18 from eric7.EricWidgets.EricProgressDialog import EricProgressDialog |
18 from eric7.SystemUtilities import FileSystemUtilities |
19 from eric7.SystemUtilities import FileSystemUtilities |
19 |
20 |
20 from .UMLDiagramBuilder import UMLDiagramBuilder |
21 from .UMLDiagramBuilder import UMLDiagramBuilder |
21 |
22 |
47 """ |
48 """ |
48 super().__init__(dialog, view, project) |
49 super().__init__(dialog, view, project) |
49 self.setObjectName("ImportsDiagram") |
50 self.setObjectName("ImportsDiagram") |
50 |
51 |
51 self.showExternalImports = showExternalImports |
52 self.showExternalImports = showExternalImports |
52 self.packagePath = os.path.abspath(package) |
53 if FileSystemUtilities.isRemoteFileName(package): |
|
54 self.packagePath = package |
|
55 else: |
|
56 self.packagePath = os.path.abspath(package) |
53 |
57 |
54 self.__relPackagePath = ( |
58 self.__relPackagePath = ( |
55 self.project.getRelativePath(self.packagePath) |
59 self.project.getRelativePath(self.packagePath) |
56 if self.project.isProjectCategory(self.packagePath, "SOURCES") |
60 if self.project.isProjectCategory(self.packagePath, "SOURCES") |
57 else "" |
61 else "" |
58 ) |
62 ) |
59 |
63 |
|
64 self.__remotefsInterface = ( |
|
65 ericApp().getObject("EricServer").getServiceInterface("FileSystem") |
|
66 ) |
|
67 |
60 def initialize(self): |
68 def initialize(self): |
61 """ |
69 """ |
62 Public method to initialize the object. |
70 Public method to initialize the object. |
63 """ |
71 """ |
64 self.package = os.path.splitdrive(self.packagePath)[1].replace(os.sep, ".")[1:] |
|
65 hasInit = True |
72 hasInit = True |
66 ppath = self.packagePath |
73 ppath = self.packagePath |
67 while hasInit: |
74 |
68 ppath = os.path.dirname(ppath) |
75 if FileSystemUtilities.isRemoteFileName(self.packagePath): |
69 hasInit = len(glob.glob(os.path.join(ppath, "__init__.*"))) > 0 |
76 self.package = ( |
|
77 FileSystemUtilities.plainFileName(self.packagePath)[1:] |
|
78 .replace("/", ".") |
|
79 .replace("\\", ".") |
|
80 ) |
|
81 while hasInit: |
|
82 ppath = self.__remotefsInterface.dirname(ppath) |
|
83 globPattern = self.__remotefsInterface.join(ppath, "__init__.*") |
|
84 hasInit = len(self.__remotefsInterface.glob(globPattern)) > 0 |
|
85 else: |
|
86 self.package = ( |
|
87 os.path.splitdrive(self.packagePath)[1][1:].replace(os.sep, ".") |
|
88 ) |
|
89 while hasInit: |
|
90 ppath = os.path.dirname(ppath) |
|
91 hasInit = len(glob.glob(os.path.join(ppath, "__init__.*"))) > 0 |
|
92 |
70 self.shortPackage = self.packagePath.replace(ppath, "").replace(os.sep, ".")[1:] |
93 self.shortPackage = self.packagePath.replace(ppath, "").replace(os.sep, ".")[1:] |
71 |
94 |
72 pname = self.project.getProjectName() |
95 pname = self.project.getProjectName() |
73 name = ( |
96 name = ( |
74 self.tr("Imports Diagramm {0}: {1}").format( |
97 self.tr("Imports Diagramm {0}: {1}").format( |
91 |
114 |
92 extensions = Preferences.getPython("Python3Extensions") |
115 extensions = Preferences.getPython("Python3Extensions") |
93 moduleDict = {} |
116 moduleDict = {} |
94 modules = [] |
117 modules = [] |
95 for ext in Preferences.getPython("Python3Extensions"): |
118 for ext in Preferences.getPython("Python3Extensions"): |
96 modules.extend( |
119 if FileSystemUtilities.isRemoteFileName(self.packagePath): |
97 glob.glob( |
120 modules.extend( |
98 FileSystemUtilities.normjoinpath( |
121 [ |
99 self.packagePath, "*{0}".format(ext) |
122 FileSystemUtilities.remoteFileName(f) |
|
123 for f in self.__remotefsInterface.glob( |
|
124 self.__remotefsInterface.join(self.packagePath, f"*{ext}") |
|
125 ) |
|
126 ] |
|
127 ) |
|
128 else: |
|
129 modules.extend( |
|
130 glob.glob( |
|
131 FileSystemUtilities.normjoinpath(self.packagePath, f"*{ext}") |
100 ) |
132 ) |
101 ) |
133 ) |
102 ) |
|
103 |
134 |
104 tot = len(modules) |
135 tot = len(modules) |
105 progress = EricProgressDialog( |
136 progress = EricProgressDialog( |
106 self.tr("Parsing modules..."), |
137 self.tr("Parsing modules..."), |
107 None, |
138 None, |
139 |
170 |
140 def buildDiagram(self): |
171 def buildDiagram(self): |
141 """ |
172 """ |
142 Public method to build the modules shapes of the diagram. |
173 Public method to build the modules shapes of the diagram. |
143 """ |
174 """ |
144 initlist = glob.glob(os.path.join(self.packagePath, "__init__.*")) |
175 if FileSystemUtilities.isRemoteFileName(self.packagePath): |
|
176 globPattern = self.__remotefsInterface.join(self.packagePath, "__init__.*") |
|
177 initlist = self.__remotefsInterface.glob(globPattern) |
|
178 else: |
|
179 initlist = glob.glob(os.path.join(self.packagePath, "__init__.*")) |
145 if len(initlist) == 0: |
180 if len(initlist) == 0: |
146 ct = QGraphicsTextItem(None) |
181 ct = QGraphicsTextItem(None) |
147 ct.setHtml( |
182 ct.setHtml( |
148 self.buildErrorMessage( |
183 self.buildErrorMessage( |
149 self.tr( |
184 self.tr( |