eric6/Graphics/PackageDiagramBuilder.py

changeset 7254
f00d825fbdb3
parent 7229
53054eb5b15a
child 7360
9190402e4505
equal deleted inserted replaced
7253:50dbe65a1334 7254:f00d825fbdb3
71 71
72 @return dictionary of modules contained in the package. 72 @return dictionary of modules contained in the package.
73 """ 73 """
74 import Utilities.ModuleParser 74 import Utilities.ModuleParser
75 75
76 supportedExt = \ 76 supportedExt = (
77 ['*{0}'.format(ext) for ext in 77 ['*{0}'.format(ext) for ext in
78 Preferences.getPython("PythonExtensions")] + \ 78 Preferences.getPython("PythonExtensions")] +
79 ['*{0}'.format(ext) for ext in 79 ['*{0}'.format(ext) for ext in
80 Preferences.getPython("Python3Extensions")] + \ 80 Preferences.getPython("Python3Extensions")] +
81 ['*.rb'] 81 ['*.rb']
82 extensions = Preferences.getPython("PythonExtensions") + \ 82 )
83 Preferences.getPython("Python3Extensions") + ['.rb'] 83 extensions = (
84 Preferences.getPython("PythonExtensions") +
85 Preferences.getPython("Python3Extensions") +
86 ['.rb']
87 )
84 88
85 moduleDict = {} 89 moduleDict = {}
86 modules = [] 90 modules = []
87 for ext in supportedExt: 91 for ext in supportedExt:
88 modules.extend(glob.glob( 92 modules.extend(glob.glob(
123 127
124 @return dictionary of sub-packages contained in this package 128 @return dictionary of sub-packages contained in this package
125 """ 129 """
126 import Utilities.ModuleParser 130 import Utilities.ModuleParser
127 131
128 supportedExt = \ 132 supportedExt = (
129 ['*{0}'.format(ext) for ext in 133 ['*{0}'.format(ext) for ext in
130 Preferences.getPython("PythonExtensions")] + \ 134 Preferences.getPython("PythonExtensions")] +
131 ['*{0}'.format(ext) for ext in 135 ['*{0}'.format(ext) for ext in
132 Preferences.getPython("Python3Extensions")] + \ 136 Preferences.getPython("Python3Extensions")] +
133 ['*.rb'] 137 ['*.rb']
134 extensions = Preferences.getPython("PythonExtensions") + \ 138 )
135 Preferences.getPython("Python3Extensions") + ['.rb'] 139 extensions = (
140 Preferences.getPython("PythonExtensions") +
141 Preferences.getPython("Python3Extensions") +
142 ['.rb']
143 )
136 144
137 subpackagesDict = {} 145 subpackagesDict = {}
138 subpackagesList = [] 146 subpackagesList = []
139 147
140 for subpackage in os.listdir(self.package): 148 for subpackage in os.listdir(self.package):
141 subpackagePath = os.path.join(self.package, subpackage) 149 subpackagePath = os.path.join(self.package, subpackage)
142 if os.path.isdir(subpackagePath) and \ 150 if (
143 subpackage != "__pycache__" and \ 151 os.path.isdir(subpackagePath) and
144 len(glob.glob(os.path.join(subpackagePath, "__init__.*"))) != 0: 152 subpackage != "__pycache__" and
153 len(glob.glob(
154 os.path.join(subpackagePath, "__init__.*")
155 )) != 0
156 ):
145 subpackagesList.append(subpackagePath) 157 subpackagesList.append(subpackagePath)
146 158
147 tot = 0 159 tot = 0
148 for ext in supportedExt: 160 for ext in supportedExt:
149 for subpackage in subpackagesList: 161 for subpackage in subpackagesList:
347 self.umlView.setSceneSize(swidth, sheight) 359 self.umlView.setSceneSize(swidth, sheight)
348 360
349 # distribute each generation across the width and the 361 # distribute each generation across the width and the
350 # generations across height 362 # generations across height
351 y = 10.0 363 y = 10.0
352 for currentWidth, currentHeight, generation in \ 364 for currentWidth, currentHeight, generation in (
353 zip_longest(widths, heights, generations): 365 zip_longest(widths, heights, generations)
366 ):
354 x = 10.0 367 x = 10.0
355 # whiteSpace is the space between any two elements 368 # whiteSpace is the space between any two elements
356 whiteSpace = (width - currentWidth - 20) / \ 369 whiteSpace = (
370 (width - currentWidth - 20) /
357 (len(generation) - 1.0 or 2.0) 371 (len(generation) - 1.0 or 2.0)
372 )
358 for className in generation: 373 for className in generation:
359 cw = self.__getCurrentShape(className) 374 cw = self.__getCurrentShape(className)
360 cw.setPos(x, y) 375 cw.setPos(x, y)
361 rect = cw.sceneBoundingRect() 376 rect = cw.sceneBoundingRect()
362 x = x + rect.width() + whiteSpace 377 x = x + rect.width() + whiteSpace
448 @param version version of the data (string) 463 @param version version of the data (string)
449 @param data persisted data to be parsed (string) 464 @param data persisted data to be parsed (string)
450 @return flag indicating success (boolean) 465 @return flag indicating success (boolean)
451 """ 466 """
452 parts = data.split(", ") 467 parts = data.split(", ")
453 if len(parts) != 2 or \ 468 if (
454 not parts[0].startswith("package=") or \ 469 len(parts) != 2 or
455 not parts[1].startswith("no_attributes="): 470 not parts[0].startswith("package=") or
471 not parts[1].startswith("no_attributes=")
472 ):
456 return False 473 return False
457 474
458 self.package = parts[0].split("=", 1)[1].strip() 475 self.package = parts[0].split("=", 1)[1].strip()
459 self.noAttrs = Utilities.toBool(parts[1].split("=", 1)[1].strip()) 476 self.noAttrs = Utilities.toBool(parts[1].split("=", 1)[1].strip())
460 477

eric ide

mercurial