Utilities/ModuleParser.py

changeset 1302
95538c8d07c1
parent 1229
a8207dc73672
child 1350
f21bedbb0c6f
equal deleted inserted replaced
1300:9083f6b7ea3b 1302:95538c8d07c1
434 @param name name of the global to add (string) 434 @param name name of the global to add (string)
435 @param attr Attribute object to be added 435 @param attr Attribute object to be added
436 """ 436 """
437 if not name in self.globals: 437 if not name in self.globals:
438 self.globals[name] = attr 438 self.globals[name] = attr
439 else:
440 self.globals[name].addAssignment(attr.lineno)
439 441
440 def addDescription(self, description): 442 def addDescription(self, description):
441 """ 443 """
442 Protected method to store the modules docstring. 444 Protected method to store the modules docstring.
443 445
1169 @param name name of the attribute to add (string) 1171 @param name name of the attribute to add (string)
1170 @param attr Attribute object to be added 1172 @param attr Attribute object to be added
1171 """ 1173 """
1172 if not name in self.attributes: 1174 if not name in self.attributes:
1173 self.attributes[name] = attr 1175 self.attributes[name] = attr
1176 else:
1177 self.attributes[name].addAssignment(attr.lineno)
1174 1178
1175 def getAttribute(self, name): 1179 def getAttribute(self, name):
1176 """ 1180 """
1177 Public method to retrieve an attribute by name. 1181 Public method to retrieve an attribute by name.
1178 1182
1191 @param name name of the global to add (string) 1195 @param name name of the global to add (string)
1192 @param attr Attribute object to be added 1196 @param attr Attribute object to be added
1193 """ 1197 """
1194 if not name in self.globals: 1198 if not name in self.globals:
1195 self.globals[name] = attr 1199 self.globals[name] = attr
1200 else:
1201 self.globals[name].addAssignment(attr.lineno)
1196 1202
1197 def addDescription(self, description): 1203 def addDescription(self, description):
1198 """ 1204 """
1199 Public method to store the class docstring. 1205 Public method to store the class docstring.
1200 1206
1287 Constructor 1293 Constructor
1288 1294
1289 @param module name of module containing this function (string) 1295 @param module name of module containing this function (string)
1290 @param name name of the function (string) 1296 @param name name of the function (string)
1291 @param file name of file containing this function (string) 1297 @param file name of file containing this function (string)
1292 @param lineno linenumber of the function definition (integer) 1298 @param lineno linenumber of the first attribute assignment (integer)
1293 @keyparam isSignal flag indicating a signal definition (boolean) 1299 @keyparam isSignal flag indicating a signal definition (boolean)
1294 """ 1300 """
1295 self.module = module 1301 self.module = module
1296 self.name = name 1302 self.name = name
1297 self.file = file 1303 self.file = file
1298 self.lineno = lineno 1304 self.lineno = lineno
1299 self.isSignal = isSignal 1305 self.isSignal = isSignal
1300 self.setPublic() 1306 self.setPublic()
1307 self.linenos = [lineno]
1308
1309 def addAssignment(self, lineno):
1310 """
1311 Public method to add another assignment line number.
1312
1313 @param lineno linenumber of the additional attribute assignment (integer)
1314 """
1315 if lineno not in self.linenos:
1316 self.linenos.append(lineno)
1301 1317
1302 1318
1303 def readModule(module, path=[], inpackage=False, basename="", 1319 def readModule(module, path=[], inpackage=False, basename="",
1304 extensions=None, caching=True): 1320 extensions=None, caching=True):
1305 ''' 1321 '''

eric ide

mercurial