eric6/Graphics/ApplicationDiagramBuilder.py

changeset 7254
f00d825fbdb3
parent 7229
53054eb5b15a
child 7360
9190402e4505
equal deleted inserted replaced
7253:50dbe65a1334 7254:f00d825fbdb3
51 application. 51 application.
52 52
53 @return dictionary of modules contained in the application. 53 @return dictionary of modules contained in the application.
54 """ 54 """
55 import Utilities.ModuleParser 55 import Utilities.ModuleParser
56 extensions = Preferences.getPython("PythonExtensions") + \ 56 extensions = (
57 Preferences.getPython("Python3Extensions") + ['.rb'] 57 Preferences.getPython("PythonExtensions") +
58 Preferences.getPython("Python3Extensions") +
59 ['.rb']
60 )
58 moduleDict = {} 61 moduleDict = {}
59 mods = self.project.pdata["SOURCES"] 62 mods = self.project.pdata["SOURCES"]
60 modules = [] 63 modules = []
61 for module in mods: 64 for module in mods:
62 modules.append(Utilities.normabsjoinpath( 65 modules.append(Utilities.normabsjoinpath(
92 95
93 def buildDiagram(self): 96 def buildDiagram(self):
94 """ 97 """
95 Public method to build the packages shapes of the diagram. 98 Public method to build the packages shapes of the diagram.
96 """ 99 """
97 project = os.path.splitdrive(self.project.getProjectPath())[1]\ 100 project = (
101 os.path.splitdrive(self.project.getProjectPath())[1]
98 .replace(os.sep, '.')[1:] 102 .replace(os.sep, '.')[1:]
103 )
99 packages = {} 104 packages = {}
100 shapes = {} 105 shapes = {}
101 p = 10 106 p = 10
102 y = 10 107 y = 10
103 maxHeight = 0 108 maxHeight = 0
150 ppath = packagePath 155 ppath = packagePath
151 while hasInit: 156 while hasInit:
152 ppath = os.path.dirname(ppath) 157 ppath = os.path.dirname(ppath)
153 hasInit = len(glob.glob(os.path.join( 158 hasInit = len(glob.glob(os.path.join(
154 ppath, '__init__.*'))) > 0 159 ppath, '__init__.*'))) > 0
155 shortPackage = packagePath.replace(ppath, '')\ 160 shortPackage = (
161 packagePath.replace(ppath, '')
156 .replace(os.sep, '.')[1:] 162 .replace(os.sep, '.')[1:]
163 )
157 packageList = shortPackage.split('.')[1:] 164 packageList = shortPackage.split('.')[1:]
158 packageListLen = len(packageList) 165 packageListLen = len(packageList)
159 i = '.'.join( 166 i = '.'.join(
160 packageList[:packageListLen - dots + 1] + 167 packageList[:packageListLen - dots + 1] +
161 [i[dots:]]) 168 [i[dots:]])
178 n = "{0}.{1}".format(project, i) 185 n = "{0}.{1}".format(project, i)
179 if n in modules: 186 if n in modules:
180 impLst.append(n) 187 impLst.append(n)
181 for imp in impLst: 188 for imp in impLst:
182 impPackage = '.'.join(imp.split('.')[:-1]) 189 impPackage = '.'.join(imp.split('.')[:-1])
183 if impPackage not in packages[package][1] and \ 190 if (
184 not impPackage == package: 191 impPackage not in packages[package][1] and
192 not impPackage == package
193 ):
185 packages[package][1].append(impPackage) 194 packages[package][1].append(impPackage)
186 195
187 sortedkeys = sorted(packages.keys()) 196 sortedkeys = sorted(packages.keys())
188 for package in sortedkeys: 197 for package in sortedkeys:
189 if package: 198 if package:
269 @param version version of the data (string) 278 @param version version of the data (string)
270 @param data persisted data to be parsed (string) 279 @param data persisted data to be parsed (string)
271 @return flag indicating success (boolean) 280 @return flag indicating success (boolean)
272 """ 281 """
273 parts = data.split(", ") 282 parts = data.split(", ")
274 if len(parts) != 2 or \ 283 if (
275 not parts[0].startswith("project=") or \ 284 len(parts) != 2 or
276 not parts[1].startswith("no_modules="): 285 not parts[0].startswith("project=") or
286 not parts[1].startswith("no_modules=")
287 ):
277 return False 288 return False
278 289
279 projectFile = parts[0].split("=", 1)[1].strip() 290 projectFile = parts[0].split("=", 1)[1].strip()
280 if projectFile != self.project.getProjectFile(): 291 if projectFile != self.project.getProjectFile():
281 res = E5MessageBox.yesNo( 292 res = E5MessageBox.yesNo(

eric ide

mercurial