/usr/share/pyshared/bike/query/relationships.py is in bicyclerepair 0.9-6.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # queries to do with module/class/function relationships
from __future__ import generators
from bike.globals import *
from getTypeOf import getTypeOf, getTypeOfExpr
from bike.parsing.newstuff import generateModuleFilenamesInPythonPath, generateModuleFilenamesInPackage, getPythonPath
from bike.parsing.pathutils import getPackageBaseDirectory
from bike.query.common import MatchFinder, walkLinesContainingStrings, getScopeForLine
from bike import log
from bike.parsing.fastparserast import Module
import re
def getRootClassesOfHierarchy(klass):
if klass is None: # i.e. dont have base class in our ast
return None
if klass.getBaseClassNames() == []: # i.e. is a root class
return [klass]
else:
rootclasses = []
for base in klass.getBaseClassNames():
baseclass = getTypeOf(klass,base)
rootclass = getRootClassesOfHierarchy(baseclass)
if rootclass is None: # base class not in our ast
rootclass = [klass]
rootclasses+=rootclass
return rootclasses
|