11 import os.path |
11 import os.path |
12 |
12 |
13 from PyQt4.QtCore import * |
13 from PyQt4.QtCore import * |
14 from PyQt4.QtGui import * |
14 from PyQt4.QtGui import * |
15 |
15 |
16 from UMLDialog import UMLDialog |
16 from .UMLDialog import UMLDialog |
17 from ClassItem import ClassItem, ClassModel |
17 from .ClassItem import ClassItem, ClassModel |
18 from AssociationItem import AssociationItem, Generalisation |
18 from .AssociationItem import AssociationItem, Generalisation |
19 import GraphicsUtilities |
19 from . import GraphicsUtilities |
20 |
20 |
21 import Utilities.ModuleParser |
21 import Utilities.ModuleParser |
22 import Utilities |
22 import Utilities |
23 |
23 |
24 class PackageDiagram(UMLDialog): |
24 class PackageDiagram(UMLDialog): |
116 return |
116 return |
117 |
117 |
118 # step 1: build all classes found in the modules |
118 # step 1: build all classes found in the modules |
119 classesFound = False |
119 classesFound = False |
120 |
120 |
121 for modName in modules.keys(): |
121 for modName in list(modules.keys()): |
122 module = modules[modName] |
122 module = modules[modName] |
123 for cls in module.classes.keys(): |
123 for cls in list(module.classes.keys()): |
124 classesFound = True |
124 classesFound = True |
125 self.__addLocalClass(cls, module.classes[cls], 0, 0) |
125 self.__addLocalClass(cls, module.classes[cls], 0, 0) |
126 if not classesFound: |
126 if not classesFound: |
127 ct = QGraphicsTextItem(None, self.scene) |
127 ct = QGraphicsTextItem(None, self.scene) |
128 ct.setHtml(\ |
128 ct.setHtml(\ |
132 |
132 |
133 # step 2: build the class hierarchies |
133 # step 2: build the class hierarchies |
134 routes = [] |
134 routes = [] |
135 nodes = [] |
135 nodes = [] |
136 |
136 |
137 for modName in modules.keys(): |
137 for modName in list(modules.keys()): |
138 module = modules[modName] |
138 module = modules[modName] |
139 todo = [module.createHierarchy()] |
139 todo = [module.createHierarchy()] |
140 while todo: |
140 while todo: |
141 hierarchy = todo[0] |
141 hierarchy = todo[0] |
142 for className in hierarchy.keys(): |
142 for className in list(hierarchy.keys()): |
143 cw = self.__getCurrentShape(className) |
143 cw = self.__getCurrentShape(className) |
144 if not cw and className.find('.') >= 0: |
144 if not cw and className.find('.') >= 0: |
145 cw = self.__getCurrentShape(className.split('.')[-1]) |
145 cw = self.__getCurrentShape(className.split('.')[-1]) |
146 if cw: |
146 if cw: |
147 self.allClasses[className] = cw |
147 self.allClasses[className] = cw |
166 self.__addExternalClass(className, 0, 0) |
166 self.__addExternalClass(className, 0, 0) |
167 nodes.append(className) |
167 nodes.append(className) |
168 |
168 |
169 if hierarchy.get(className): |
169 if hierarchy.get(className): |
170 todo.append(hierarchy.get(className)) |
170 todo.append(hierarchy.get(className)) |
171 children = hierarchy.get(className).keys() |
171 children = list(hierarchy.get(className).keys()) |
172 for child in children: |
172 for child in children: |
173 if (className, child) not in routes: |
173 if (className, child) not in routes: |
174 routes.append((className, child)) |
174 routes.append((className, child)) |
175 |
175 |
176 del todo[0] |
176 del todo[0] |