Graphics/PackageDiagramBuilder.py

branch
Py2 comp.
changeset 3060
5883ce99ee12
parent 3058
0a02c433f52d
parent 3035
36e9f388958b
child 3080
6c0a430b19df
equal deleted inserted replaced
3058:0a02c433f52d 3060:5883ce99ee12
74 @return dictionary of modules contained in the package. 74 @return dictionary of modules contained in the package.
75 """ 75 """
76 import Utilities.ModuleParser 76 import Utilities.ModuleParser
77 77
78 supportedExt = \ 78 supportedExt = \
79 ['*{0}'.format(ext) for ext in 79 ['*{0}'.format(ext) for ext in
80 Preferences.getPython("PythonExtensions")] + \ 80 Preferences.getPython("PythonExtensions")] + \
81 ['*{0}'.format(ext) for ext in 81 ['*{0}'.format(ext) for ext in
82 Preferences.getPython("Python3Extensions")] + \ 82 Preferences.getPython("Python3Extensions")] + \
83 ['*.rb'] 83 ['*.rb']
84 extensions = Preferences.getPython("PythonExtensions") + \ 84 extensions = Preferences.getPython("PythonExtensions") + \
85 Preferences.getPython("Python3Extensions") + ['.rb'] 85 Preferences.getPython("Python3Extensions") + ['.rb']
86 86
125 @return dictionary of sub-packages contained in this package 125 @return dictionary of sub-packages contained in this package
126 """ 126 """
127 import Utilities.ModuleParser 127 import Utilities.ModuleParser
128 128
129 supportedExt = \ 129 supportedExt = \
130 ['*{0}'.format(ext) for ext in 130 ['*{0}'.format(ext) for ext in
131 Preferences.getPython("PythonExtensions")] + \ 131 Preferences.getPython("PythonExtensions")] + \
132 ['*{0}'.format(ext) for ext in 132 ['*{0}'.format(ext) for ext in
133 Preferences.getPython("Python3Extensions")] + \ 133 Preferences.getPython("Python3Extensions")] + \
134 ['*.rb'] 134 ['*.rb']
135 extensions = Preferences.getPython("PythonExtensions") + \ 135 extensions = Preferences.getPython("PythonExtensions") + \
136 Preferences.getPython("Python3Extensions") + ['.rb'] 136 Preferences.getPython("Python3Extensions") + ['.rb']
137 137
198 198
199 initlist = glob.glob(os.path.join(self.package, '__init__.*')) 199 initlist = glob.glob(os.path.join(self.package, '__init__.*'))
200 if len(initlist) == 0: 200 if len(initlist) == 0:
201 ct = QGraphicsTextItem(None, self.scene) 201 ct = QGraphicsTextItem(None, self.scene)
202 ct.setHtml( 202 ct.setHtml(
203 self.trUtf8("The directory <b>'{0}'</b> is not a package.")\ 203 self.trUtf8("The directory <b>'{0}'</b> is not a package.")
204 .format(self.package)) 204 .format(self.package))
205 return 205 return
206 206
207 modules = self.__buildModulesDict() 207 modules = self.__buildModulesDict()
208 if not modules: 208 if not modules:
209 ct = QGraphicsTextItem(None, self.scene) 209 ct = QGraphicsTextItem(None, self.scene)
210 ct.setHtml( 210 ct.setHtml(
211 self.trUtf8( 211 self.trUtf8(
212 "The package <b>'{0}'</b> does not contain any modules.") 212 "The package <b>'{0}'</b> does not contain any modules.")
213 .format(self.package)) 213 .format(self.package))
214 return 214 return
215 215
216 # step 1: build all classes found in the modules 216 # step 1: build all classes found in the modules
217 classesFound = False 217 classesFound = False
218 218
224 if not classesFound: 224 if not classesFound:
225 ct = QGraphicsTextItem(None, self.scene) 225 ct = QGraphicsTextItem(None, self.scene)
226 ct.setHtml( 226 ct.setHtml(
227 self.trUtf8( 227 self.trUtf8(
228 "The package <b>'{0}'</b> does not contain any classes.") 228 "The package <b>'{0}'</b> does not contain any classes.")
229 .format(self.package)) 229 .format(self.package))
230 return 230 return
231 231
232 # step 2: build the class hierarchies 232 # step 2: build the class hierarchies
233 routes = [] 233 routes = []
234 nodes = [] 234 nodes = []
244 cw = self.__getCurrentShape(className.split('.')[-1]) 244 cw = self.__getCurrentShape(className.split('.')[-1])
245 if cw: 245 if cw:
246 self.allClasses[className] = cw 246 self.allClasses[className] = cw
247 if cw and cw.noAttrs != self.noAttrs: 247 if cw and cw.noAttrs != self.noAttrs:
248 cw = None 248 cw = None
249 if cw and not (cw.external and \ 249 if cw and not (cw.external and
250 (className in module.classes or 250 (className in module.classes or
251 className in module.modules) 251 className in module.modules)
252 ): 252 ):
253 if className not in nodes: 253 if className not in nodes:
254 nodes.append(className) 254 nodes.append(className)
255 else: 255 else:
256 if className in module.classes: 256 if className in module.classes:
257 # this is a local class (defined in this module) 257 # this is a local class (defined in this module)
426 """ 426 """
427 from .AssociationItem import AssociationItem, Generalisation 427 from .AssociationItem import AssociationItem, Generalisation
428 for route in routes: 428 for route in routes:
429 if len(route) > 1: 429 if len(route) > 1:
430 assoc = AssociationItem( 430 assoc = AssociationItem(
431 self.__getCurrentShape(route[1]), 431 self.__getCurrentShape(route[1]),
432 self.__getCurrentShape(route[0]), 432 self.__getCurrentShape(route[0]),
433 Generalisation, 433 Generalisation,
434 topToBottom=True) 434 topToBottom=True)
435 self.scene.addItem(assoc) 435 self.scene.addItem(assoc)
436 436
437 def getPersistenceData(self): 437 def getPersistenceData(self):
438 """ 438 """
439 Public method to get a string for data to be persisted. 439 Public method to get a string for data to be persisted.

eric ide

mercurial