本文整理汇总了Python中spyder.config.main.CONF类的典型用法代码示例。如果您正苦于以下问题:Python CONF类的具体用法?Python CONF怎么用?Python CONF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CONF类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: lsp_manager
def lsp_manager(qtbot_module, request):
"""LSP manager instance for tests."""
# Activate pycodestyle and pydocstyle
CONF.set('lsp-server', 'pycodestyle', True)
CONF.set('lsp-server', 'pydocstyle', True)
# Create the manager
os.environ['SPY_TEST_USE_INTROSPECTION'] = 'True'
manager = LSPManager(parent=MainWindowMock())
# Wait for the client to be started
editor = manager.main.editor
with qtbot_module.waitSignal(editor.sig_lsp_initialized, timeout=30000):
manager.start_client('python')
settings = editor.lsp_editor_settings['python']
assert all([option in SERVER_CAPABILITES for option in settings.keys()])
def teardown():
manager.shutdown()
os.environ['SPY_TEST_USE_INTROSPECTION'] = 'False'
CONF.set('lsp-server', 'pycodestyle', False)
CONF.set('lsp-server', 'pydocstyle', False)
request.addfinalizer(teardown)
return manager
开发者ID:impact27,项目名称:spyder,代码行数:26,代码来源:fixtures.py
示例2: delete_scheme
def delete_scheme(self):
"""Deletes the currently selected custom color scheme."""
scheme_name = self.current_scheme
answer = QMessageBox.warning(self, _("Warning"),
_("Are you sure you want to delete "
"this scheme?"),
QMessageBox.Yes | QMessageBox.No)
if answer == QMessageBox.Yes:
# Put the combobox in Spyder by default, when deleting a scheme
names = self.get_option('names')
self.set_scheme('spyder')
self.schemes_combobox.setCurrentIndex(names.index('spyder'))
self.set_option('selected', 'spyder')
# Delete from custom_names
custom_names = self.get_option('custom_names', [])
if scheme_name in custom_names:
custom_names.remove(scheme_name)
self.set_option('custom_names', custom_names)
# Delete config options
for key in syntaxhighlighters.COLOR_SCHEME_KEYS:
option = "{0}/{1}".format(scheme_name, key)
CONF.remove_option(self.CONF_SECTION, option)
CONF.remove_option(self.CONF_SECTION,
"{0}/name".format(scheme_name))
self.update_combobox()
self.update_preview()
开发者ID:impact27,项目名称:spyder,代码行数:30,代码来源:appearance.py
示例3: set_option
def set_option(self, option, value):
"""
Set a plugin option in configuration file
Use a SIGNAL to call it, e.g.:
plugin.sig_option_changed.emit('show_all', checked)
"""
CONF.set(self.CONF_SECTION, str(option), value)
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:7,代码来源:__init__.py
示例4: update_preview
def update_preview(self, index=None, scheme_name=None):
"""
Update the color scheme of the preview editor and adds text.
Note
----
'index' is needed, because this is triggered by a signal that sends
the selected index.
"""
text = ('"""A string"""\n\n'
'# A comment\n\n'
'# %% A cell\n\n'
'class Foo(object):\n'
' def __init__(self):\n'
' bar = 42\n'
' print(bar)\n'
)
show_blanks = CONF.get('editor', 'blank_spaces')
update_scrollbar = CONF.get('editor', 'scroll_past_end')
if scheme_name is None:
scheme_name = self.current_scheme
self.preview_editor.setup_editor(linenumbers=True,
markers=True,
tab_mode=False,
font=get_font(),
show_blanks=show_blanks,
color_scheme=scheme_name,
scroll_past_end=update_scrollbar)
self.preview_editor.set_text(text)
self.preview_editor.set_language('Python')
开发者ID:impact27,项目名称:spyder,代码行数:30,代码来源:appearance.py
示例5: reset_namespace
def reset_namespace(self, warning=False, silent=True):
"""Reset the namespace by removing all names defined by the user."""
reset_str = _("Reset IPython namespace")
warn_str = _("All user-defined variables will be removed."
"<br>Are you sure you want to reset the namespace?")
if warning:
box = MessageCheckBox(icon=QMessageBox.Warning, parent=self)
box.setWindowTitle(reset_str)
box.set_checkbox_text(_("Don't show again."))
box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
box.setDefaultButton(QMessageBox.No)
box.set_checked(False)
box.set_check_visible(True)
box.setText(warn_str)
answer = box.exec_()
# Update checkbox based on user interaction
CONF.set('ipython_console', 'show_reset_namespace_warning',
not box.is_checked())
if answer != QMessageBox.Yes:
return
if self._reading:
self.dbg_exec_magic('reset', '-f')
else:
if silent:
self.silent_execute("%reset -f")
self.refresh_namespacebrowser()
else:
self.execute("%reset -f")
开发者ID:rlaverde,项目名称:spyder,代码行数:34,代码来源:shell.py
示例6: get_font
def get_font(section='appearance', option='font', font_size_delta=0):
"""Get console font properties depending on OS and user options"""
font = FONT_CACHE.get((section, option))
if font is None:
families = CONF.get(section, option+"/family", None)
if families is None:
return QFont()
family = get_family(families)
weight = QFont.Normal
italic = CONF.get(section, option+'/italic', False)
if CONF.get(section, option+'/bold', False):
weight = QFont.Bold
size = CONF.get(section, option+'/size', 9) + font_size_delta
font = QFont(family, size, weight)
font.setItalic(italic)
FONT_CACHE[(section, option)] = font
size = CONF.get(section, option+'/size', 9) + font_size_delta
font.setPointSize(size)
return font
开发者ID:cfanpc,项目名称:spyder,代码行数:25,代码来源:gui.py
示例7: argv
def argv(self):
"""Command to start kernels"""
# Python interpreter used to start kernels
if CONF.get('main_interpreter', 'default'):
pyexec = get_python_executable()
else:
# Avoid IPython adding the virtualenv on which Spyder is running
# to the kernel sys.path
os.environ.pop('VIRTUAL_ENV', None)
pyexec = CONF.get('main_interpreter', 'executable')
# Fixes Issue #3427
if os.name == 'nt':
dir_pyexec = osp.dirname(pyexec)
pyexec_w = osp.join(dir_pyexec, 'pythonw.exe')
if osp.isfile(pyexec_w):
pyexec = pyexec_w
# Command used to start kernels
utils_path = osp.join(self.spy_path, 'utils', 'ipython')
kernel_cmd = [
pyexec,
osp.join("%s" % utils_path, "start_kernel.py"),
'-f',
'{connection_file}'
]
return kernel_cmd
开发者ID:0xBADCA7,项目名称:spyder,代码行数:28,代码来源:kernelspec.py
示例8: save_connection_settings
def save_connection_settings(self):
"""Save user's kernel connection settings."""
if not self.save_layout.isChecked():
return
is_ssh_key = bool(self.kf_radio.isChecked())
connection_settings = {
"json_file_path": self.cf.text(),
"is_remote": self.rm_group.isChecked(),
"username": self.un.text(),
"hostname": self.hn.text(),
"port": self.pn.text(),
"is_ssh_keyfile": is_ssh_key,
"ssh_key_file_path": self.kf.text()
}
CONF.set("existing-kernel", "settings", connection_settings)
try:
import keyring
if is_ssh_key:
keyring.set_password("spyder_remote_kernel",
"ssh_key_passphrase",
self.kfp.text())
else:
keyring.set_password("spyder_remote_kernel",
"ssh_password",
self.pw.text())
except Exception:
pass
开发者ID:impact27,项目名称:spyder,代码行数:30,代码来源:kernelconnect.py
示例9: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.main = parent
# Widgets
self.pages_widget = QStackedWidget()
self.pages_widget.setMinimumWidth(600)
self.contents_widget = QListWidget()
self.button_reset = QPushButton(_('Reset to defaults'))
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply |
QDialogButtonBox.Cancel)
self.apply_btn = bbox.button(QDialogButtonBox.Apply)
# Widgets setup
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowTitle(_('Preferences'))
self.setWindowIcon(ima.icon('configure'))
self.contents_widget.setMovement(QListView.Static)
self.contents_widget.setSpacing(1)
self.contents_widget.setCurrentRow(0)
self.contents_widget.setMinimumWidth(220)
self.contents_widget.setMinimumHeight(400)
# Layout
hsplitter = QSplitter()
hsplitter.addWidget(self.contents_widget)
hsplitter.addWidget(self.pages_widget)
hsplitter.setStretchFactor(0, 1)
hsplitter.setStretchFactor(1, 2)
btnlayout = QHBoxLayout()
btnlayout.addWidget(self.button_reset)
btnlayout.addStretch(1)
btnlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(hsplitter)
vlayout.addLayout(btnlayout)
self.setLayout(vlayout)
# Signals and slots
if self.main:
self.button_reset.clicked.connect(self.main.reset_spyder)
self.pages_widget.currentChanged.connect(self.current_page_changed)
self.contents_widget.currentRowChanged.connect(
self.pages_widget.setCurrentIndex)
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
bbox.clicked.connect(self.button_clicked)
# Ensures that the config is present on spyder first run
CONF.set('main', 'interface_language', load_lang_conf())
开发者ID:impact27,项目名称:spyder,代码行数:59,代码来源:configdialog.py
示例10: save_bookmarks
def save_bookmarks(filename, bookmarks):
"""Save all bookmarks from specific file to config."""
if not osp.isfile(filename):
return
slots = load_bookmarks_without_file(filename)
for slot_num, content in bookmarks.items():
slots[slot_num] = [filename, content[0], content[1]]
CONF.set('editor', 'bookmarks', slots)
开发者ID:impact27,项目名称:spyder,代码行数:8,代码来源:bookmarks.py
示例11: set_option
def set_option(self, option, value):
"""
Set a plugin option in configuration file.
Note: Use sig_option_changed to call it from widgets of the
same or another plugin.
"""
CONF.set(self.CONF_SECTION, str(option), value)
开发者ID:impact27,项目名称:spyder,代码行数:8,代码来源:plugins.py
示例12: get_user_credentials
def get_user_credentials(self):
"""Get user credentials with the login dialog."""
password = None
token = None
(username, remember_me,
remember_token) = self._get_credentials_from_settings()
valid_py_os = not (PY2 and sys.platform.startswith('linux'))
if username and remember_me and valid_py_os:
# Get password from keyring
try:
password = keyring.get_password('github', username)
except Exception:
# No safe keyring backend
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to retrieve password'),
_('It was not possible to retrieve '
'your password. Please introduce '
'it again.'))
if remember_token and valid_py_os:
# Get token from keyring
try:
token = keyring.get_password('github', 'token')
except Exception:
# No safe keyring backend
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to retrieve token'),
_('It was not possible to retrieve '
'your token. Please introduce it '
'again.'))
if not running_under_pytest():
credentials = DlgGitHubLogin.login(self.parent_widget, username,
password, token, remember_me,
remember_token)
if (credentials['username'] and credentials['password'] and
valid_py_os):
self._store_credentials(credentials['username'],
credentials['password'],
credentials['remember'])
CONF.set('main', 'report_error/remember_me',
credentials['remember'])
if credentials['token'] and valid_py_os:
self._store_token(credentials['token'],
credentials['remember_token'])
CONF.set('main', 'report_error/remember_token',
credentials['remember_token'])
else:
return dict(username=username,
password=password,
token='',
remember=remember_me,
remember_token=remember_token)
return credentials
开发者ID:burrbull,项目名称:spyder,代码行数:58,代码来源:backend.py
示例13: reset_namespace
def reset_namespace(self, warning=False, message=False):
"""Reset the namespace by removing all names defined by the user."""
reset_str = _("Remove all variables")
warn_str = _("All user-defined variables will be removed. "
"Are you sure you want to proceed?")
kernel_env = self.kernel_manager._kernel_spec.env
if warning:
box = MessageCheckBox(icon=QMessageBox.Warning, parent=self)
box.setWindowTitle(reset_str)
box.set_checkbox_text(_("Don't show again."))
box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
box.setDefaultButton(QMessageBox.Yes)
box.set_checked(False)
box.set_check_visible(True)
box.setText(warn_str)
answer = box.exec_()
# Update checkbox based on user interaction
CONF.set('ipython_console', 'show_reset_namespace_warning',
not box.is_checked())
self.ipyclient.reset_warning = not box.is_checked()
if answer != QMessageBox.Yes:
return
try:
if self._reading:
self.dbg_exec_magic('reset', '-f')
else:
if message:
self.reset()
self._append_html(_("<br><br>Removing all variables..."
"\n<hr>"),
before_prompt=False)
self.silent_execute("%reset -f")
if kernel_env.get('SPY_AUTOLOAD_PYLAB_O') == 'True':
self.silent_execute("from pylab import *")
if kernel_env.get('SPY_SYMPY_O') == 'True':
sympy_init = """
from __future__ import division
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
init_printing()"""
self.silent_execute(dedent(sympy_init))
if kernel_env.get('SPY_RUN_CYTHON') == 'True':
self.silent_execute("%reload_ext Cython")
self.refresh_namespacebrowser()
if not self.external_kernel:
self.silent_execute(
'get_ipython().kernel.close_all_mpl_figures()')
except AttributeError:
pass
开发者ID:impact27,项目名称:spyder,代码行数:58,代码来源:shell.py
示例14: _get_credentials_from_settings
def _get_credentials_from_settings(self):
"""Get the stored credentials if any."""
remember_me = CONF.get('main', 'report_error/remember_me')
remember_token = CONF.get('main', 'report_error/remember_token')
username = CONF.get('main', 'report_error/username', '')
if not remember_me:
username = ''
return username, remember_me, remember_token
开发者ID:burrbull,项目名称:spyder,代码行数:9,代码来源:backend.py
示例15: update_margins
def update_margins(self):
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)
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:9,代码来源:__init__.py
示例16: _get_run_configurations
def _get_run_configurations():
history_count = CONF.get('run', 'history', 20)
try:
return [(filename, options)
for filename, options in CONF.get('run', 'configurations', [])
if osp.isfile(filename)][:history_count]
except ValueError:
CONF.set('run', 'configurations', [])
return []
开发者ID:burrbull,项目名称:spyder,代码行数:9,代码来源:runconfig.py
示例17: is_dark_interface
def is_dark_interface():
ui_theme = CONF.get('appearance', 'ui_theme')
color_scheme = CONF.get('appearance', 'selected')
if ui_theme == 'dark':
return True
elif ui_theme == 'automatic':
if not is_dark_font_color(color_scheme):
return True
else:
return False
else:
return False
开发者ID:cfanpc,项目名称:spyder,代码行数:12,代码来源:gui.py
示例18: teardown
def teardown():
"""Clear existing-kernel config and keyring passwords."""
CONF.remove_section("existing-kernel")
try:
import keyring
keyring.set_password("spyder_remote_kernel",
"ssh_key_passphrase", "")
keyring.set_password("spyder_remote_kernel",
"ssh_password", "")
except Exception:
pass
开发者ID:impact27,项目名称:spyder,代码行数:12,代码来源:test_kernelconnect.py
示例19: external_editor
def external_editor(self, filename, goto=-1):
"""Edit in an external editor
Recommended: SciTE (e.g. to go to line where an error did occur)"""
editor_path = CONF.get("internal_console", "external_editor/path")
goto_option = CONF.get("internal_console", "external_editor/gotoline")
try:
args = [filename]
if goto > 0 and goto_option:
args.append("%s%d".format(goto_option, goto))
programs.run_program(editor_path, args)
except OSError:
self.write_error("External editor was not found:" " %s\n" % editor_path)
开发者ID:jitseniesen,项目名称:spyder,代码行数:12,代码来源:internalshell.py
示例20: argv
def argv(self):
"""Command to start kernels"""
# Python interpreter used to start kernels
if CONF.get('main_interpreter', 'default'):
pyexec = get_python_executable()
else:
# Avoid IPython adding the virtualenv on which Spyder is running
# to the kernel sys.path
os.environ.pop('VIRTUAL_ENV', None)
pyexec = CONF.get('main_interpreter', 'executable')
if not is_python_interpreter(pyexec):
pyexec = get_python_executable()
CONF.set('main_interpreter', 'executable', '')
CONF.set('main_interpreter', 'default', True)
CONF.set('main_interpreter', 'custom', False)
# Fixes Issue #3427
if os.name == 'nt':
dir_pyexec = osp.dirname(pyexec)
pyexec_w = osp.join(dir_pyexec, 'pythonw.exe')
if osp.isfile(pyexec_w):
pyexec = pyexec_w
# Command used to start kernels
kernel_cmd = [
pyexec,
'-m',
'spyder_kernels.console',
'-f',
'{connection_file}'
]
return kernel_cmd
开发者ID:impact27,项目名称:spyder,代码行数:33,代码来源:kernelspec.py
注:本文中的spyder.config.main.CONF类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论