Example #1
0
def globalScanForMatches(contextFilename, matchFinder, targetname, pythonpath):
    for sourcenode in getSourceNodesContainingRegex(targetname, contextFilename, pythonpath):
        print >> log.progress, "Scanning", sourcenode.filename
        searchscope = sourcenode.fastparseroot
        for match in scanScopeForMatches(sourcenode,searchscope,
                                         matchFinder,targetname):
            yield match
Example #2
0
def globalScanForMatches(contextFilename, matchFinder, targetname):
    for sourcenode in getSourceNodesContainingRegex(targetname, contextFilename):
        log.progress.write("Scanning %s\n" % (sourcenode.filename,))
        searchscope = sourcenode.fastparseroot
        for match in scanScopeForMatches(sourcenode,searchscope,
                                         matchFinder,targetname):
            yield match
Example #3
0
def globalScanForMatches(contextFilename, matchFinder, targetname):
    for sourcenode in getSourceNodesContainingRegex(targetname, contextFilename):
        print >> log.progress, "Scanning", sourcenode.filename
        searchscope = sourcenode.fastparseroot
        for match in scanScopeForMatches(sourcenode,searchscope,
                                         matchFinder,targetname):
            yield match
 def test_works(self):
     try:
         createPackageStructure("# testregexfoobah","pass")
         srcfiles = [s for s in 
                     getSourceNodesContainingRegex("testregexfoobah",
                                                   pkgstructureFile2)]
         self.assertEqual(pkgstructureFile1,srcfiles[0].filename)
     finally:
         removePackageStructure()
Example #5
0
 def test_works(self):
     try:
         createPackageStructure("# testregexfoobah", "pass")
         srcfiles = [
             s for s in getSourceNodesContainingRegex(
                 "testregexfoobah", pkgstructureFile2, [])
         ]
         self.assertEqual(pkgstructureFile1, srcfiles[0].filename)
     finally:
         removePackageStructure()
Example #6
0
def scanPythonPathForMatchingMethodNames(name, contextFilename):
    class MethodFinder:
        def __init__(self,srcnode):
            self.matches = []
            self.srcnode = srcnode
        def visitFunction(self,node):
            node = getScopeForLine(self.srcnode, self.lineno)
            if isinstance(node.getParent(),Class):
                if node.name == name:
                    self.matches.append(convertNodeToMatchObject(node,50))

    for srcnode in getSourceNodesContainingRegex(name,contextFilename):
        m = MethodFinder(srcnode)
        walkLinesContainingStrings(srcnode.fastparseroot,m,[name])
        for match in m.matches:
            yield match
Example #7
0
def _generateCoordsMatchingString(word,filenameToStartSearchFrom,pythonpath):
    for sourcenode in getSourceNodesContainingRegex(word, filenameToStartSearchFrom, pythonpath):
        for linenum,col in sourcenode.getWordCoordsMatchingString(word):
            yield sourcenode,linenum,col
Example #8
0
def scanPythonPathForMatchingMethodNames(name, contextFilename, pythonpath):
    for srcnode in getSourceNodesContainingRegex(name,contextFilename,pythonpath):
        for scope in srcnode.getFlattenedListOfScopes():
            if scope.name == name and scopeIsAMethod(scope):
                yield convertScopeToMatchObject(scope,50)