def getProjectSpecificModules(path="", onlySpecified=False): " Provides a dictionary of the project specific modules " specificModules = {} importDirs = [] if not onlySpecified: importDirs = GlobalData().getProjectImportDirs() for importPath in importDirs: specificModules.update(getModules(importPath)) projectFile = GlobalData().project.fileName if projectFile != "": basedir = os.path.dirname(projectFile) if basedir not in importDirs: importDirs.append(basedir) specificModules.update(getModules(basedir)) if path and os.path.isabs(path): path = os.path.normpath(path) basedir = "" if os.path.isfile(path): basedir = os.path.dirname(path) elif os.path.isdir(path): basedir = path if basedir and basedir not in importDirs: specificModules.update(getModules(basedir)) return specificModules
def getProjectSpecificModules( path = "", onlySpecified = False ): " Provides a dictionary of the project specific modules " specificModules = {} importDirs = [] if not onlySpecified: importDirs = GlobalData().getProjectImportDirs() for importPath in importDirs: specificModules.update( getModules( importPath ) ) projectFile = GlobalData().project.fileName if projectFile != "": basedir = os.path.dirname( projectFile ) if basedir not in importDirs: importDirs.append( basedir ) specificModules.update( getModules( basedir ) ) if path and os.path.isabs( path ): path = os.path.normpath( path ) basedir = "" if os.path.isfile( path ): basedir = os.path.dirname( path ) elif os.path.isdir( path ): basedir = path if basedir and basedir not in importDirs: specificModules.update( getModules( basedir ) ) return specificModules
def getJediScript(source, line, column, srcPath, needSysPath=True): """Provides the jedi Script object considering the current project""" jedi.settings.additional_dynamic_modules = [] paths = GlobalData().originalSysPath[:] if needSysPath else [] # This make relative imports resolvable if os.path.isabs(srcPath): dirName = os.path.dirname(srcPath) if dirName not in paths: paths.append(dirName) project = GlobalData().project if not project.isLoaded(): # Add the other opened files if so mainWindow = GlobalData().mainWindow for path in mainWindow.editorsManager().getOpenedList(): if path[0]: if path[0].lower().endswith('.py'): jedi.settings.additional_dynamic_modules.append(path[0]) return jedi.Script(source, line, column, srcPath, sys_path=paths) for path in project.getImportDirsAsAbsolutePaths(): if path not in paths: paths.append(path) projectDir = project.getProjectDir() if projectDir not in paths: paths.append(projectDir) return jedi.Script(source, line, column, srcPath, sys_path=paths)