def generateRefsToName(name,scope,sourcenode,defnmatch): assert scope is not None if isinstance(scope,Function): # search can be limited to scope return scanScopeForMatches(sourcenode,scope, NameRefFinder(name,defnmatch), name) else: return globalScanForMatches(sourcenode.filename, NameRefFinder(name,defnmatch), name)
def findDefinitionOfAttributeFromASTNode(type,name): assert isinstance(type,Class) attrfinder = AttrbuteDefnFinder([type],name) # first scan the method names: for child in type.getChildNodes(): if child.name == name: return convertNodeToMatchObject(child,100) # then scan the method source for attribues for child in type.getChildNodes(): if isinstance(child,Function): try: return scanScopeForMatches(child.module.getSourceNode(), child, attrfinder, name).next() except StopIteration: continue