~vil/pydev/upstream

« back to all changes in this revision

Viewing changes to org.python.pydev/PySrc/ThirdParty/brm/bike/query/relationships.py

  • Committer: Vladimír Lapáček
  • Date: 2006-08-30 18:38:44 UTC
  • Revision ID: vladimir.lapacek@gmail.com-20060830183844-f4d82c1239a7770a
Initial import of upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# queries to do with module/class/function relationships
 
2
from __future__ import generators
 
3
from bike.globals import *
 
4
from getTypeOf import getTypeOf, getTypeOfExpr
 
5
from bike.parsing.newstuff import generateModuleFilenamesInPythonPath, generateModuleFilenamesInPackage, getPythonPath
 
6
from bike.parsing.pathutils import getPackageBaseDirectory
 
7
from bike.query.common import MatchFinder, walkLinesContainingStrings, getScopeForLine
 
8
from bike import log
 
9
from bike.parsing.fastparserast import Module
 
10
import re
 
11
 
 
12
def getRootClassesOfHierarchy(klass):
 
13
    if klass is None:  # i.e. dont have base class in our ast
 
14
        return None
 
15
    if klass.getBaseClassNames() == []:  # i.e. is a root class
 
16
        return [klass]
 
17
    else:
 
18
        rootclasses = []
 
19
        for base in klass.getBaseClassNames():
 
20
            baseclass = getTypeOf(klass,base)
 
21
            rootclass = getRootClassesOfHierarchy(baseclass)
 
22
            if rootclass is None:  # base class not in our ast
 
23
                rootclass = [klass]
 
24
            rootclasses+=rootclass
 
25
        return rootclasses
 
26