30 def __init__(self, dialog, view, project, package, |
30 def __init__(self, dialog, view, project, package, |
31 showExternalImports=False): |
31 showExternalImports=False): |
32 """ |
32 """ |
33 Constructor |
33 Constructor |
34 |
34 |
35 @param dialog reference to the UML dialog (UMLDialog) |
35 @param dialog reference to the UML dialog |
36 @param view reference to the view object (UMLGraphicsView) |
36 @type UMLDialog |
37 @param project reference to the project object (Project) |
37 @param view reference to the view object |
|
38 @type UMLGraphicsView |
|
39 @param project reference to the project object |
|
40 @type Project |
38 @param package name of a python package to show the import |
41 @param package name of a python package to show the import |
39 relationships (string) |
42 relationships |
|
43 @type str |
40 @param showExternalImports flag indicating to show exports from |
44 @param showExternalImports flag indicating to show exports from |
41 outside the package (boolean) |
45 outside the package |
|
46 @type bool |
42 """ |
47 """ |
43 super().__init__(dialog, view, project) |
48 super().__init__(dialog, view, project) |
44 self.setObjectName("ImportsDiagram") |
49 self.setObjectName("ImportsDiagram") |
45 |
50 |
46 self.showExternalImports = showExternalImports |
51 self.showExternalImports = showExternalImports |
72 def __buildModulesDict(self): |
77 def __buildModulesDict(self): |
73 """ |
78 """ |
74 Private method to build a dictionary of modules contained in the |
79 Private method to build a dictionary of modules contained in the |
75 package. |
80 package. |
76 |
81 |
77 @return dictionary of modules contained in the package. |
82 @return dictionary of modules contained in the package |
|
83 @rtype dict |
78 """ |
84 """ |
79 import Utilities.ModuleParser |
85 import Utilities.ModuleParser |
80 extensions = ( |
86 extensions = ( |
81 Preferences.getPython("Python3Extensions") |
87 Preferences.getPython("Python3Extensions") |
82 ) |
88 ) |
200 |
206 |
201 def __addModule(self, name, classes, x, y): |
207 def __addModule(self, name, classes, x, y): |
202 """ |
208 """ |
203 Private method to add a module to the diagram. |
209 Private method to add a module to the diagram. |
204 |
210 |
205 @param name module name to be shown (string) |
211 @param name module name to be shown |
|
212 @type str |
206 @param classes list of class names contained in the module |
213 @param classes list of class names contained in the module |
207 (list of strings) |
214 @type list of str |
208 @param x x-coordinate (float) |
215 @param x x-coordinate |
209 @param y y-coordinate (float) |
216 @type float |
210 @return reference to the imports item (ModuleItem) |
217 @param y y-coordinate |
|
218 @type float |
|
219 @return reference to the imports item |
|
220 @rtype ModuleItem |
211 """ |
221 """ |
212 from .ModuleItem import ModuleItem, ModuleModel |
222 from .ModuleItem import ModuleItem, ModuleModel |
213 classes.sort() |
223 classes.sort() |
214 impM = ModuleModel(name, classes) |
224 impM = ModuleModel(name, classes) |
215 impW = ModuleItem(impM, x, y, scene=self.scene, |
225 impW = ModuleItem(impM, x, y, scene=self.scene, |
314 |
324 |
315 def getPersistenceData(self): |
325 def getPersistenceData(self): |
316 """ |
326 """ |
317 Public method to get a string for data to be persisted. |
327 Public method to get a string for data to be persisted. |
318 |
328 |
319 @return persisted data string (string) |
329 @return persisted data string |
|
330 @rtype str |
320 """ |
331 """ |
321 return "package={0}, show_external={1}".format( |
332 return "package={0}, show_external={1}".format( |
322 self.packagePath, self.showExternalImports) |
333 self.packagePath, self.showExternalImports) |
323 |
334 |
324 def parsePersistenceData(self, version, data): |
335 def parsePersistenceData(self, version, data): |
325 """ |
336 """ |
326 Public method to parse persisted data. |
337 Public method to parse persisted data. |
327 |
338 |
328 @param version version of the data (string) |
339 @param version version of the data |
329 @param data persisted data to be parsed (string) |
340 @type str |
330 @return flag indicating success (boolean) |
341 @param data persisted data to be parsed |
|
342 @type str |
|
343 @return flag indicating success |
|
344 @rtype bool |
331 """ |
345 """ |
332 parts = data.split(", ") |
346 parts = data.split(", ") |
333 if ( |
347 if ( |
334 len(parts) != 2 or |
348 len(parts) != 2 or |
335 not parts[0].startswith("package=") or |
349 not parts[0].startswith("package=") or |