def getModuleUsingFQN(fqn, pythonpath): filename = getPathOfModuleOrPackage(fqn,pythonpath) if filename is not None: if os.path.isdir(filename): return getModule(os.path.join(filename,"__init__.py")) else: return getModule(filename) else: return None
def takes_a_filename_and_returns_a_module_object(self): f = file("tmpfile.py", "w+").write("pass") try: m = getModule("tmpfile.py") assert isinstance(m, Module) finally: os.remove("tmpfile.py")
def takes_a_filename_and_returns_a_module_object(self): f = file("tmpfile.py","w+").write("pass") try: m = getModule("tmpfile.py") assert isinstance(m,Module) finally: os.remove("tmpfile.py")
def translateSourceCoordsIntoASTNode(filename,lineno,col): module = getModule(filename) maskedlines = module.getMaskedModuleLines() lline,backtrackchars = getLogicalLine(module, lineno) doctoredline = makeLineParseable(lline) ast = compiler.parse(doctoredline) idx = backtrackchars+col nodefinder = ASTNodeFinder(lline,idx) node = compiler.walk(ast, nodefinder).node if node is None: raise CouldNotLocateNodeException("Could not translate editor coordinates into source node") return node
def getModuleOrPackageUsingFQN(fqn, dirpath=None): pythonpath = getPythonPath() #print_ "getModuleOrPackageUsingFQN",pythonpath,fqn if dirpath is not None: assert os.path.isdir(dirpath) pythonpath = [dirpath] + pythonpath filename = getPathOfModuleOrPackage(fqn, pythonpath) #print_ "getModuleOrPackageUsingFQN - filename",filename if filename is not None: if os.path.isdir(filename): return getPackage(filename) else: return getModule(filename) else: return None
def getModuleOrPackageUsingFQN(fqn, dirpath=None): pythonpath = getPythonPath() #print "getModuleOrPackageUsingFQN",pythonpath,fqn if dirpath is not None: assert os.path.isdir(dirpath) pythonpath = [dirpath] + pythonpath filename = getPathOfModuleOrPackage(fqn,pythonpath) #print "getModuleOrPackageUsingFQN - filename",filename if filename is not None: if os.path.isdir(filename): return getPackage(filename) else: return getModule(filename) else: return None
def represents_a_python_module(self): f = file("tmpfile.py", "w+").write("pass") try: m = getModule("tmpfile.py") finally: os.remove("tmpfile.py")
def returns_None_if_file_doesnt_exist(self): assert_equal(None, getModule("filedoesntexist"))
def represents_a_python_module(self): f = file("tmpfile.py","w+").write("pass") try: m = getModule("tmpfile.py") finally: os.remove("tmpfile.py")
def returns_None_if_file_doesnt_exist(self): assert_equal(None,getModule("filedoesntexist"))