Return Spyder PYTHONPATH
336106
def get_spyder_pythonpath(self):
        """"""
        active_path = [p for p in self.path if p not in self.not_active_path]
        return active_path + self.project_path
128329
def import_path(self):
    """"""
    return os.path.join(self.remote_root, self.pkg) if self.pkg else self.remote_root
1262644
def importcmd(self, image_path, input_source):
    '''
       
    '''
    from spython.utils import check_install
    check_install()

    cmd = ['singularity', 'image.import', image_path, input_source]
    output = self.run_command(cmd, sudo=False)
    self.println(output)        
    return image_path
1130177
def path_for_import(name):
    
    return os.path.dirname(os.path.abspath(import_module(name).__file__))
36725
def _get_spyderplugins(plugin_path, is_io, modnames, modlist):
    """"""
    if not osp.isdir(plugin_path):
        return

    for name in os.listdir(plugin_path):
        # This is needed in order to register the spyder_io_hdf5 plugin.
        # See issue 4487
        # Is this a Spyder plugin?
        if not name.startswith(PLUGIN_PREFIX):
            continue

        # Ensure right type of plugin
        if is_io != name.startswith(IO_PREFIX):
            continue

        # Skip names that end in certain suffixes
        forbidden_suffixes = ['dist-info', 'egg.info', 'egg-info', 'egg-link',
                              'kernels']
        if any([name.endswith(s) for s in forbidden_suffixes]):
            continue

        # Import the plugin
        _import_plugin(name, plugin_path, modnames, modlist)
854556
function guessPython () {
    log.verbose('could not find "' + python + '". guessing location')
    var rootDir = process.env.SystemDrive || 'C:\\'
    if (rootDir[rootDir.length - 1] !== '\\') {
      rootDir += '\\'
    }
    var pythonPath = path.resolve(rootDir, 'Python27', 'python.exe')
    log.verbose('ensuring that file exists:', pythonPath)
    fs.stat(pythonPath, function (err, stat) {
      if (err) {
        if (err.code == 'ENOENT') {
          failNoPython()
        } else {
          callback(err)
        }
        return
      }
      python = pythonPath
      checkPythonVersion()
    })
  }
651050
def get_imported_module_from_file(file_path):
        
        if p_compat.is_py3:
            imported_module = importlib.machinery.SourceFileLoader('module_name', file_path).load_module()
        elif p_compat.is_py2:
            imported_module = imp.load_source('module_name', file_path)
        else:
            raise RuntimeError("Neither Python 3 nor Python 2.")
    
        return imported_module
861269
def get_python_path(venv_path):
    
    # Get `bin` directory path
    bin_path = get_bin_path(venv_path)

    # Get `python` program path
    program_path = os.path.join(bin_path, 'python')

    # If the platform is Windows
    if sys.platform.startswith('win'):
        # Add `.exe` suffix to the `python` program path
        program_path = program_path + '.exe'

    # Return the `python` program path
    return program_path
994533
def get_scraper(mod_path, scraper_type):
    

    # act of importing puts it into the registry
    try:
        module = importlib.import_module(mod_path)
    except ImportError as e:
        raise ScrapeError("could not import %s" % mod_path, e)

    # now find the class within the module
    ScraperClass = None

    for k, v in module.__dict__.items():
        if k.startswith('_'):
            continue
        if getattr(v, 'scraper_type', None) == scraper_type:
            if ScraperClass:
                raise ScrapeError("two %s scrapers found in module %s: %s %s" %
                                  (scraper_type, mod_path, ScraperClass, k))
            ScraperClass = v

    if not ScraperClass:
        raise ScrapeError("no %s scraper found in module %s" % (
            scraper_type, mod_path))

    return ScraperClass
1291422
def coderelpath(coderoot, relpath):
    """"""
    from os import chdir, getcwd, path
    cd = getcwd()
    chdir(coderoot)
    result = path.abspath(relpath)
    chdir(cd)
    return result
777925
def env(self):
        """"""
        # Add our PYTHONPATH to the kernel
        pathlist = CONF.get('main', 'spyder_pythonpath', default=[])

        default_interpreter = CONF.get('main_interpreter', 'default')
        pypath = add_pathlist_to_PYTHONPATH([], pathlist, ipyconsole=True,
                                            drop_env=False)

        # Environment variables that we need to pass to our sitecustomize
        umr_namelist = CONF.get('main_interpreter', 'umr/namelist')

        if PY2:
            original_list = umr_namelist[:]
            for umr_n in umr_namelist:
                try:
                    umr_n.encode('utf-8')
                except UnicodeDecodeError:
                    umr_namelist.remove(umr_n)
            if original_list != umr_namelist:
                CONF.set('main_interpreter', 'umr/namelist', umr_namelist)

        env_vars = {
            'SPY_EXTERNAL_INTERPRETER': not default_interpreter,
            'SPY_UMR_ENABLED': CONF.get('main_interpreter', 'umr/enabled'),
            'SPY_UMR_VERBOSE': CONF.get('main_interpreter', 'umr/verbose'),
            'SPY_UMR_NAMELIST': ','.join(umr_namelist),
            'SPY_RUN_LINES_O': CONF.get('ipython_console', 'startup/run_lines'),
            'SPY_PYLAB_O': CONF.get('ipython_console', 'pylab'),
            'SPY_BACKEND_O': CONF.get('ipython_console', 'pylab/backend'),
            'SPY_AUTOLOAD_PYLAB_O': CONF.get('ipython_console',
                                             'pylab/autoload'),
            'SPY_FORMAT_O': CONF.get('ipython_console',
                                     'pylab/inline/figure_format'),
            'SPY_BBOX_INCHES_O': CONF.get('ipython_console',
                                          'pylab/inline/bbox_inches'),
            'SPY_RESOLUTION_O': CONF.get('ipython_console',
                                         'pylab/inline/resolution'),
            'SPY_WIDTH_O': CONF.get('ipython_console', 'pylab/inline/width'),
            'SPY_HEIGHT_O': CONF.get('ipython_console', 'pylab/inline/height'),
            'SPY_USE_FILE_O': CONF.get('ipython_console',
                                       'startup/use_run_file'),
            'SPY_RUN_FILE_O': CONF.get('ipython_console', 'startup/run_file'),
            'SPY_AUTOCALL_O': CONF.get('ipython_console', 'autocall'),
            'SPY_GREEDY_O': CONF.get('ipython_console', 'greedy_completer'),
            'SPY_JEDI_O': CONF.get('ipython_console', 'jedi_completer'),
            'SPY_SYMPY_O': CONF.get('ipython_console', 'symbolic_math'),
            'SPY_TESTING': running_under_pytest() or SAFE_MODE,
            'SPY_HIDE_CMD': CONF.get('ipython_console', 'hide_cmd_windows')
        }

        if self.is_pylab is True:
            env_vars['SPY_AUTOLOAD_PYLAB_O'] = True
            env_vars['SPY_SYMPY_O'] = False
            env_vars['SPY_RUN_CYTHON'] = False
        if self.is_sympy is True:
            env_vars['SPY_AUTOLOAD_PYLAB_O'] = False
            env_vars['SPY_SYMPY_O'] = True
            env_vars['SPY_RUN_CYTHON'] = False
        if self.is_cython is True:
            env_vars['SPY_AUTOLOAD_PYLAB_O'] = False
            env_vars['SPY_SYMPY_O'] = False
            env_vars['SPY_RUN_CYTHON'] = True

        # Add our PYTHONPATH to env_vars
        env_vars.update(pypath)

        # Making all env_vars strings
        for key,var in iteritems(env_vars):
            if PY2:
                # Try to convert vars first to utf-8.
                try:
                    unicode_var = to_text_string(var)
                except UnicodeDecodeError:
                    # If that fails, try to use the file system
                    # encoding because one of our vars is our
                    # PYTHONPATH, and that contains file system
                    # directories
                    try:
                        unicode_var = to_unicode_from_fs(var)
                    except:
                        # If that also fails, make the var empty
                        # to be able to start Spyder.
                        # See https://stackoverflow.com/q/44506900/438386
                        # for details.
                        unicode_var = ''
                env_vars[key] = to_binary_string(unicode_var,
                                                 encoding='utf-8')
            else:
                env_vars[key] = to_text_string(var)
        return env_vars
237784
def get_python_files(self):
        """"""
        return [resource for resource in self.get_files()
                if self.pycore.is_python_file(resource)]
473651
def get_source(self, objtxt):
        """"""
        from spyder_kernels.utils.dochelpers import getsource

        obj, valid = self._eval(objtxt)
        if valid:
            return getsource(obj)
1120621
def path_manager_callback(self):
        """"""
        from spyder.widgets.pathmanager import PathManager
        self.remove_path_from_sys_path()
        project_path = self.projects.get_pythonpath()
        dialog = PathManager(self, self.path, project_path,
                             self.not_active_path, sync=True)
        dialog.redirect_stdio.connect(self.redirect_internalshell_stdio)
        dialog.exec_()
        self.add_path_to_sys_path()
        try:
            encoding.writelines(self.path, self.SPYDER_PATH) # Saving path
            encoding.writelines(self.not_active_path,
                                self.SPYDER_NOT_ACTIVE_PATH)
        except EnvironmentError:
            pass
        self.sig_pythonpath_changed.emit()
943973
def python(self, cmd):
        """"""
        python_bin = self.cmd_path('python')
        cmd = '{0} {1}'.format(python_bin, cmd)
        return self._execute(cmd)
105986
@VisibleForTesting
  Path getWindowsPythonPath() {
    String cloudSdkPython = System.getenv("CLOUDSDK_PYTHON");
    if (cloudSdkPython != null) {
      Path cloudSdkPythonPath = Paths.get(cloudSdkPython);
      if (Files.exists(cloudSdkPythonPath)) {
        return cloudSdkPythonPath;
      } else {
        throw new InvalidPathException(cloudSdkPython, "python binary not in specified location");
      }
    }

    Path pythonPath = getPath().resolve(WINDOWS_BUNDLED_PYTHON);
    if (Files.exists(pythonPath)) {
      return pythonPath;
    } else {
      return Paths.get("python");
    }
  }
486150
def get_tree(config=None):
    ''' 
    '''
    path = os.path.dirname(os.path.abspath(__file__))
    pypath = os.path.realpath(os.path.join(path, '..', 'python'))
    if pypath not in sys.path:
        sys.path.append(pypath)
    os.chdir(pypath)
    from tree.tree import Tree
    tree = Tree(config=config)
    return tree