How to use the spyder.config.manager.CONF.get function in spyder

To help you get started, we’ve selected a few spyder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spyder-ide / spyder / spyder / plugins / base.py View on Github external
def _update_margins(self):
        """Update plugin margins"""
        layout = self.layout()
        if self._default_margins is None:
            self._default_margins = layout.getContentsMargins()
        if CONF.get('main', 'use_custom_margin'):
            margin = CONF.get('main', 'custom_margin')
            layout.setContentsMargins(*[margin]*4)
        else:
            layout.setContentsMargins(*self._default_margins)
github spyder-ide / spyder / spyder / plugins / console / widgets / shell.py View on Github external
def load_history(self):
        """Load history from a .py file in user home directory"""
        if osp.isfile(self.history_filename):
            rawhistory, _ = encoding.readlines(self.history_filename)
            rawhistory = [line.replace('\n', '') for line in rawhistory]
            if rawhistory[1] != self.INITHISTORY[1]:
                rawhistory[1] = self.INITHISTORY[1]
        else:
            rawhistory = self.INITHISTORY
        history = [line for line in rawhistory \
                   if line and not line.startswith('#')]

        # Truncating history to X entries:
        while len(history) >= CONF.get('historylog', 'max_entries'):
            del history[0]
            while rawhistory[0].startswith('#'):
                del rawhistory[0]
            del rawhistory[0]

        # Saving truncated history:
        try:
            encoding.writelines(rawhistory, self.history_filename)
        except EnvironmentError:
            pass

        return history
github spyder-ide / spyder / spyder / plugins / ipythonconsole / plugin.py View on Github external
shellwidget.sig_pdb_step.connect(
                              lambda fname, lineno, shellwidget=shellwidget:
                              self.pdb_has_stopped(fname, lineno, shellwidget))

        # To handle %edit magic petitions
        shellwidget.custom_edit_requested.connect(self.edit_file)

        # Set shell cwd according to preferences
        cwd_path = ''
        if CONF.get('workingdir', 'console/use_project_or_home_directory'):
            cwd_path = get_home_dir()
            if (self.main.projects is not None and
                    self.main.projects.get_active_project() is not None):
                cwd_path = self.main.projects.get_active_project_path()
        elif CONF.get('workingdir', 'startup/use_fixed_directory'):
            cwd_path = CONF.get('workingdir', 'startup/fixed_directory',
                                default=get_home_dir())
        elif CONF.get('workingdir', 'console/use_fixed_directory'):
            cwd_path = CONF.get('workingdir', 'console/fixed_directory')

        if osp.isdir(cwd_path) and self.main is not None:
            shellwidget.set_cwd(cwd_path)
            if give_focus:
                # Syncronice cwd with explorer and cwd widget
                shellwidget.update_cwd()

        # Connect text widget to Help
        if self.main.help is not None:
            control.set_help(self.main.help)
            control.set_help_enabled(CONF.get('help', 'connect/ipython_console'))

        # Connect client to our history log
github spyder-ide / spyder / spyder / preferences / configdialog.py View on Github external
def get_option(self, option, default=NoDefault, section=None):
        section = self.CONF_SECTION if section is None else section
        return CONF.get(section, option, default)
github spyder-ide / spyder / spyder / plugins / editor / plugin.py View on Github external
runcellcopy_n = 'run_cell_copy'
            runcellcopy_o = self.get_option(runcellcopy_n)
            closepar_n = 'close_parentheses'
            closepar_o = self.get_option(closepar_n)
            close_quotes_n = 'close_quotes'
            close_quotes_o = self.get_option(close_quotes_n)
            add_colons_n = 'add_colons'
            add_colons_o = self.get_option(add_colons_n)
            autounindent_n = 'auto_unindent'
            autounindent_o = self.get_option(autounindent_n)
            indent_chars_n = 'indent_chars'
            indent_chars_o = self.get_option(indent_chars_n)
            tab_stop_width_spaces_n = 'tab_stop_width_spaces'
            tab_stop_width_spaces_o = self.get_option(tab_stop_width_spaces_n)
            help_n = 'connect_to_oi'
            help_o = CONF.get('help', 'connect/editor')
            todo_n = 'todo_list'
            todo_o = self.get_option(todo_n)

            finfo = self.get_current_finfo()


            for editorstack in self.editorstacks:
                # Checkable options
                if blanks_n in options:
                    editorstack.set_blanks_enabled(blanks_o)
                if scrollpastend_n in options:
                    editorstack.set_scrollpastend_enabled(scrollpastend_o)
                if indentguides_n in options:
                    editorstack.set_indent_guides(indentguides_o)
                if classfuncdropdown_n in options:
                    editorstack.set_classfunc_dropdown_visible(
github spyder-ide / spyder / spyder / utils / qthelpers.py View on Github external
"""
    if sys.platform == "darwin":
        SpyderApplication = MacApplication
    else:
        SpyderApplication = QApplication

    app = SpyderApplication.instance()
    if app is None:
        # Set Application name for Gnome 3
        # https://groups.google.com/forum/#!topic/pyside/24qxvwfrRDs
        app = SpyderApplication(['Spyder'])

        # Set application name for KDE. See spyder-ide/spyder#2207.
        app.setApplicationName('Spyder')

    if sys.platform == "darwin" and CONF.get('main', 'mac_open_file', False):
        # Register app if setting is set
        register_app_launchservices()

    if translate:
        install_translator(app)

    test_ci = os.environ.get('TEST_CI_WIDGETS', None)
    if test_ci is not None:
        timer_shutdown = QTimer(app)
        timer_shutdown.timeout.connect(app.quit)
        timer_shutdown.start(test_time*1000)
    return app

github spyder-ide / spyder / spyder / preferences / runconfig.py View on Github external
def set(self, options):
        self.args = options.get('args', '')
        self.args_enabled = options.get('args/enabled', False)
        self.current = options.get('current',
                           CONF.get('run', CURRENT_INTERPRETER_OPTION, True))
        self.systerm = options.get('systerm',
                           CONF.get('run', SYSTERM_INTERPRETER_OPTION, False))
        self.interact = options.get('interact',
                           CONF.get('run', 'interact', False))
        self.post_mortem = options.get('post_mortem',
                           CONF.get('run', 'post_mortem', False))
        self.python_args = options.get('python_args', '')
        self.python_args_enabled = options.get('python_args/enabled', False)
        self.clear_namespace = options.get('clear_namespace',
                                    CONF.get('run', 'clear_namespace', False))
        self.console_namespace = options.get('console_namespace',
                                   CONF.get('run', 'console_namespace', False))
        self.file_dir = options.get('file_dir',
                           CONF.get('run', WDIR_USE_SCRIPT_DIR_OPTION, True))
        self.cw_dir = options.get('cw_dir',
                           CONF.get('run', WDIR_USE_CWD_DIR_OPTION, False))
        self.fixed_dir = options.get('fixed_dir',
                           CONF.get('run', WDIR_USE_FIXED_DIR_OPTION, False))
        self.dir = options.get('dir', '')
github spyder-ide / spyder / spyder / plugins / editor / plugin.py View on Github external
conf_name (str): configuration setting associated with the
                action
            method (str): name of EditorStack class that will be used
                to update the changes in each editorstack.
        """
        def toogle(checked):
            self.switch_to_plugin()
            self._toggle_checkable_action(checked, method, conf_name)

        action = create_action(self, text, toggled=toogle)
        action.blockSignals(True)

        if conf_name not in ['pycodestyle', 'pydocstyle']:
            action.setChecked(self.get_option(conf_name))
        else:
            action.setChecked(CONF.get('lsp-server', conf_name))

        action.blockSignals(False)

        return action
github spyder-ide / spyder / spyder / plugins / variableexplorer / widgets / objectexplorer / objectexplorer.py View on Github external
def _update_details_for_item(self, tree_item):
        """Shows the object details in the editor given an tree_item."""
        try:
            # obj = tree_item.obj
            button_id = self.button_group.checkedId()
            assert button_id >= 0, ("No radio button selected. "
                                    "Please report this bug.")
            attr_details = self._attr_details[button_id]
            data = attr_details.data_fn(tree_item)
            self.editor.setPlainText(data)
            self.editor.setWordWrapMode(attr_details.line_wrap)
            show_blanks = CONF.get('editor', 'blank_spaces')
            update_scrollbar = CONF.get('editor', 'scroll_past_end')
            scheme_name = CONF.get('appearance', 'selected')
            self.editor.setup_editor(tab_mode=False,
                                     font=get_font(),
                                     show_blanks=show_blanks,
                                     color_scheme=scheme_name,
                                     scroll_past_end=update_scrollbar)
            self.editor.set_text(data)
            if attr_details.name == 'Source code':
                self.editor.set_language('Python')
            else:
                self.editor.set_language('Rst')
        except Exception as ex:
            self.editor.setStyleSheet("color: red;")
            stack_trace = traceback.format_exc()
            self.editor.setPlainText("{}\n\n{}".format(ex, stack_trace))
            self.editor.setWordWrapMode(
                QTextOption.WrapAtWordBoundaryOrAnywhere)
github spyder-ide / spyder / spyder / app / start.py View on Github external
try:
            from locale import getlocale
            getlocale()
        except ValueError:
            # This can fail on Windows. See spyder-ide/spyder#6886.
            try:
                os.environ['LANG'] = 'C'
                os.environ['LC_ALL'] = 'C'
            except Exception:
                pass

    if options.debug_info:
        levels = {'minimal': '2', 'verbose': '3'}
        os.environ['SPYDER_DEBUG'] = levels[options.debug_info]

    if (CONF.get('main', 'single_instance') and not options.new_instance
            and not options.reset_config_files
            and not running_in_mac_app(check_file=True)):
        # Minimal delay (0.1-0.2 secs) to avoid that several
        # instances started at the same time step in their
        # own foots while trying to create the lock file
        time.sleep(random.randrange(1000, 2000, 90)/10000.)

        # Lock file creation
        lock_file = get_conf_path('spyder.lock')
        lock = lockfile.FilesystemLock(lock_file)

        # Try to lock spyder.lock. If it's *possible* to do it, then
        # there is no previous instance running and we can start a
        # new one. If *not*, then there is an instance already
        # running, which is locking that file
        try: