105 modules = self.__buildModulesDict() |
105 modules = self.__buildModulesDict() |
106 sortedkeys = sorted(modules.keys()) |
106 sortedkeys = sorted(modules.keys()) |
107 |
107 |
108 # step 1: build a dictionary of packages |
108 # step 1: build a dictionary of packages |
109 for module in sortedkeys: |
109 for module in sortedkeys: |
110 l = module.split('.') |
110 li = module.split('.') |
111 package = '.'.join(l[:-1]) |
111 package = '.'.join(li[:-1]) |
112 if package in packages: |
112 if package in packages: |
113 packages[package][0].append(l[-1]) |
113 packages[package][0].append(li[-1]) |
114 else: |
114 else: |
115 packages[package] = ([l[-1]], []) |
115 packages[package] = ([li[-1]], []) |
116 |
116 |
117 # step 2: assign modules to dictionaries and update import relationship |
117 # step 2: assign modules to dictionaries and update import relationship |
118 for module in sortedkeys: |
118 for module in sortedkeys: |
119 l = module.split('.') |
119 li = module.split('.') |
120 package = '.'.join(l[:-1]) |
120 package = '.'.join(li[:-1]) |
121 impLst = [] |
121 impLst = [] |
122 for i in modules[module].imports: |
122 for i in modules[module].imports: |
123 if i in modules: |
123 if i in modules: |
124 impLst.append(i) |
124 impLst.append(i) |
125 else: |
125 else: |
154 shortPackage = packagePath.replace(ppath, '')\ |
154 shortPackage = packagePath.replace(ppath, '')\ |
155 .replace(os.sep, '.')[1:] |
155 .replace(os.sep, '.')[1:] |
156 packageList = shortPackage.split('.')[1:] |
156 packageList = shortPackage.split('.')[1:] |
157 packageListLen = len(packageList) |
157 packageListLen = len(packageList) |
158 i = '.'.join( |
158 i = '.'.join( |
159 packageList[:packageListLen - dots + 1] + |
159 packageList[:packageListLen - dots + 1] + |
160 [i[dots:]]) |
160 [i[dots:]]) |
161 |
161 |
162 if i in modules: |
162 if i in modules: |
163 impLst.append(i) |
163 impLst.append(i) |
164 else: |
164 else: |
246 """ |
246 """ |
247 from .AssociationItem import AssociationItem, Imports |
247 from .AssociationItem import AssociationItem, Imports |
248 for package in shapes: |
248 for package in shapes: |
249 for rel in shapes[package][1]: |
249 for rel in shapes[package][1]: |
250 assoc = AssociationItem( |
250 assoc = AssociationItem( |
251 shapes[package][0], shapes[rel][0], |
251 shapes[package][0], shapes[rel][0], |
252 Imports) |
252 Imports) |
253 self.scene.addItem(assoc) |
253 self.scene.addItem(assoc) |
254 |
254 |
255 def getPersistenceData(self): |
255 def getPersistenceData(self): |
256 """ |
256 """ |
257 Public method to get a string for data to be persisted. |
257 Public method to get a string for data to be persisted. |