/usr/share/pyshared/bike/parsing/load.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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | from bike.globals import *
import os
from bike.parsing.fastparser import fastparser
class Cache:
def __init__(self):
self.reset()
def reset(self):
self.srcnodecache = {}
self.typecache = {}
self.maskedlinescache = {}
instance = None
Cache.instance = Cache()
class CantLocateSourceNodeException(Exception): pass
def getSourceNode(filename_path):
#print "getSourceNode:",filename_path
sourcenode = None
try:
sourcenode = Cache.instance.srcnodecache[filename_path]
except KeyError:
pass
if sourcenode is None:
from bike.parsing.newstuff import translateFnameToModuleName
sourcenode = SourceFile.createFromFile(filename_path,
translateFnameToModuleName(filename_path))
if sourcenode is None:
raise CantLocateSourceNodeException(filename_path)
Cache.instance.srcnodecache[filename_path]=sourcenode
return sourcenode
class SourceFile:
def createFromString(filename, modulename, src):
return SourceFile(filename,modulename,src)
createFromString = staticmethod(createFromString)
def createFromFile(filename,modulename):
try:
f = file(filename)
src = f.read()
f.close()
except IOError:
return None
else:
return SourceFile(filename,modulename,src)
createFromFile = staticmethod(createFromFile)
def __init__(self, filename, modulename, src):
if os.path.isabs(filename):
self.filename = filename
else:
self.filename = os.path.abspath(filename)
self.modulename = modulename
self.resetWithSource(src)
def resetWithSource(self, source):
# fastparser ast
self.fastparseroot = fastparser(source,self.modulename,self.filename)
self.fastparseroot.setSourceNode(self)
self._lines = source.splitlines(1)
self.sourcenode = self
def __repr__(self):
return "Source(%s,%s)"%('source', self.filename)
def getChildNodes(self):
return self.fastparseroot.getChildNodes()
def getSource(self):
return "".join(self.getLines())
def getLine(self,linenum):
return self.getLines()[linenum-1]
# TODO: rename me!
def getFlattenedListOfFastParserASTNodes(self):
return self.fastparseroot.getFlattenedListOfChildNodes()
def getLines(self):
return self._lines
|