本文整理汇总了Python中traitlets.config.loader.Config._merge方法的典型用法代码示例。如果您正苦于以下问题:Python Config._merge方法的具体用法?Python Config._merge怎么用?Python Config._merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类traitlets.config.loader.Config
的用法示例。
在下文中一共展示了Config._merge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shellwidget_config
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import _merge [as 别名]
def shellwidget_config(self):
"""
Generate a Config instance for shell widgets using our config
system
This lets us create each widget with its own config (as opposed to
IPythonQtConsoleApp, where all widgets have the same config)
"""
# ---- IPython config ----
try:
profile_path = osp.join(get_ipython_dir(), 'profile_default')
full_ip_cfg = load_pyconfig_files(['ipython_qtconsole_config.py'],
profile_path)
# From the full config we only select the IPythonWidget section
# because the others have no effect here.
ip_cfg = Config({'IPythonWidget': full_ip_cfg.IPythonWidget})
except:
ip_cfg = Config()
# ---- Spyder config ----
spy_cfg = Config()
# Make the pager widget a rich one (i.e a QTextEdit)
spy_cfg.IPythonWidget.kind = 'rich'
# Gui completion widget
completion_type_o = CONF.get('ipython_console', 'completion_type')
completions = {0: "droplist", 1: "ncurses", 2: "plain"}
spy_cfg.IPythonWidget.gui_completion = completions[completion_type_o]
# Pager
pager_o = self.get_option('use_pager')
if pager_o:
spy_cfg.IPythonWidget.paging = 'inside'
else:
spy_cfg.IPythonWidget.paging = 'none'
# Calltips
calltips_o = self.get_option('show_calltips')
spy_cfg.IPythonWidget.enable_calltips = calltips_o
# Buffer size
buffer_size_o = self.get_option('buffer_size')
spy_cfg.IPythonWidget.buffer_size = buffer_size_o
# Prompts
in_prompt_o = self.get_option('in_prompt')
out_prompt_o = self.get_option('out_prompt')
if in_prompt_o:
spy_cfg.IPythonWidget.in_prompt = in_prompt_o
if out_prompt_o:
spy_cfg.IPythonWidget.out_prompt = out_prompt_o
# Merge IPython and Spyder configs. Spyder prefs will have prevalence
# over IPython ones
ip_cfg._merge(spy_cfg)
return ip_cfg
示例2: kernel_config
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import _merge [as 别名]
#.........这里部分代码省略.........
except:
ip_cfg = Config()
# ---- Spyder config ----
spy_cfg = Config()
# Until we implement Issue 1052
spy_cfg.InteractiveShell.xmode = 'Plain'
# Run lines of code at startup
run_lines_o = CONF.get('ipython_console', 'startup/run_lines')
if run_lines_o:
spy_cfg.IPKernelApp.exec_lines = [x.strip() for x in run_lines_o.split(',')]
else:
spy_cfg.IPKernelApp.exec_lines = []
# Pylab configuration
mpl_backend = None
mpl_installed = is_module_installed('matplotlib')
pylab_o = CONF.get('ipython_console', 'pylab')
external_interpreter = \
os.environ.get('EXTERNAL_INTERPRETER', '').lower() == "true"
if mpl_installed and pylab_o:
# Get matplotlib backend
if not external_interpreter:
if os.environ["QT_API"] == 'pyqt5':
qt_backend = 'qt5'
else:
qt_backend = 'qt'
backend_o = CONF.get('ipython_console', 'pylab/backend', 0)
backends = {0: 'inline', 1: qt_backend, 2: qt_backend, 3: 'osx',
4: 'gtk', 5: 'wx', 6: 'tk'}
mpl_backend = backends[backend_o]
else:
mpl_backend = 'inline'
# Automatically load Pylab and Numpy, or only set Matplotlib
# backend
autoload_pylab_o = CONF.get('ipython_console', 'pylab/autoload')
if autoload_pylab_o:
spy_cfg.IPKernelApp.exec_lines.append(
"%pylab {0}".format(mpl_backend))
else:
spy_cfg.IPKernelApp.exec_lines.append(
"%matplotlib {0}".format(mpl_backend))
# Inline backend configuration
if backends[backend_o] == 'inline':
# Figure format
format_o = CONF.get('ipython_console',
'pylab/inline/figure_format', 0)
formats = {0: 'png', 1: 'svg'}
spy_cfg.InlineBackend.figure_format = formats[format_o]
# Resolution
spy_cfg.InlineBackend.rc = {'figure.figsize': (6.0, 4.0),
'savefig.dpi': 72,
'font.size': 10,
'figure.subplot.bottom': .125,
'figure.facecolor': 'white',
'figure.edgecolor': 'white'
}
resolution_o = CONF.get('ipython_console',
'pylab/inline/resolution')
spy_cfg.InlineBackend.rc['savefig.dpi'] = resolution_o
# Figure size
width_o = float(CONF.get('ipython_console', 'pylab/inline/width'))
height_o = float(CONF.get('ipython_console', 'pylab/inline/height'))
spy_cfg.InlineBackend.rc['figure.figsize'] = (width_o, height_o)
# Run a file at startup
use_file_o = CONF.get('ipython_console', 'startup/use_run_file')
run_file_o = CONF.get('ipython_console', 'startup/run_file')
if use_file_o and run_file_o:
spy_cfg.IPKernelApp.file_to_run = run_file_o
# Autocall
autocall_o = CONF.get('ipython_console', 'autocall')
spy_cfg.ZMQInteractiveShell.autocall = autocall_o
# To handle the banner by ourselves in IPython 3+
spy_cfg.ZMQInteractiveShell.banner1 = ''
# Greedy completer
greedy_o = CONF.get('ipython_console', 'greedy_completer')
spy_cfg.IPCompleter.greedy = greedy_o
# Sympy loading
sympy_o = CONF.get('ipython_console', 'symbolic_math')
if sympy_o:
lines = sympy_config(mpl_backend)
spy_cfg.IPKernelApp.exec_lines.append(lines)
# Merge IPython and Spyder configs. Spyder prefs will have prevalence
# over IPython ones
ip_cfg._merge(spy_cfg)
return ip_cfg
示例3: kernel_config
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import _merge [as 别名]
#.........这里部分代码省略.........
spy_cfg.IPKernelApp.exec_lines = []
# Clean terminal arguments input
clear_argv = "import sys;sys.argv = [''];del sys"
spy_cfg.IPKernelApp.exec_lines.append(clear_argv)
# Pylab configuration
mpl_backend = None
mpl_installed = is_module_installed('matplotlib')
pylab_o = CONF.get('ipython_console', 'pylab')
if mpl_installed and pylab_o:
# Get matplotlib backend
backend_o = CONF.get('ipython_console', 'pylab/backend')
if backend_o == 1:
if is_module_installed('PyQt5'):
auto_backend = 'qt5'
elif is_module_installed('PyQt4'):
auto_backend = 'qt4'
elif is_module_installed('_tkinter'):
auto_backend = 'tk'
else:
auto_backend = 'inline'
else:
auto_backend = ''
backends = {0: 'inline', 1: auto_backend, 2: 'qt5', 3: 'qt4',
4: 'osx', 5: 'gtk3', 6: 'gtk', 7: 'wx', 8: 'tk'}
mpl_backend = backends[backend_o]
# Automatically load Pylab and Numpy, or only set Matplotlib
# backend
autoload_pylab_o = CONF.get('ipython_console', 'pylab/autoload')
if autoload_pylab_o:
spy_cfg.IPKernelApp.exec_lines.append(
"%pylab {0}".format(mpl_backend))
else:
spy_cfg.IPKernelApp.exec_lines.append(
"%matplotlib {0}".format(mpl_backend))
# Inline backend configuration
if mpl_backend == 'inline':
# Figure format
format_o = CONF.get('ipython_console',
'pylab/inline/figure_format', 0)
formats = {0: 'png', 1: 'svg'}
spy_cfg.InlineBackend.figure_format = formats[format_o]
# Resolution
if is_module_installed('ipykernel', '<4.5'):
dpi_option = 'savefig.dpi'
else:
dpi_option = 'figure.dpi'
spy_cfg.InlineBackend.rc = {'figure.figsize': (6.0, 4.0),
dpi_option: 72,
'font.size': 10,
'figure.subplot.bottom': .125,
'figure.facecolor': 'white',
'figure.edgecolor': 'white'}
resolution_o = CONF.get('ipython_console',
'pylab/inline/resolution')
spy_cfg.InlineBackend.rc[dpi_option] = resolution_o
# Figure size
width_o = float(CONF.get('ipython_console', 'pylab/inline/width'))
height_o = float(CONF.get('ipython_console', 'pylab/inline/height'))
spy_cfg.InlineBackend.rc['figure.figsize'] = (width_o, height_o)
# Enable Cython magic
if is_module_installed('Cython'):
spy_cfg.IPKernelApp.exec_lines.append('%load_ext Cython')
# Run a file at startup
use_file_o = CONF.get('ipython_console', 'startup/use_run_file')
run_file_o = CONF.get('ipython_console', 'startup/run_file')
if use_file_o and run_file_o:
spy_cfg.IPKernelApp.file_to_run = run_file_o
# Autocall
autocall_o = CONF.get('ipython_console', 'autocall')
spy_cfg.ZMQInteractiveShell.autocall = autocall_o
# To handle the banner by ourselves in IPython 3+
spy_cfg.ZMQInteractiveShell.banner1 = ''
# Greedy completer
greedy_o = CONF.get('ipython_console', 'greedy_completer')
spy_cfg.IPCompleter.greedy = greedy_o
# Sympy loading
sympy_o = CONF.get('ipython_console', 'symbolic_math')
if sympy_o and is_module_installed('sympy'):
lines = sympy_config(mpl_backend)
spy_cfg.IPKernelApp.exec_lines.append(lines)
# Merge IPython and Spyder configs. Spyder prefs will have prevalence
# over IPython ones
cfg._merge(spy_cfg)
return cfg
示例4: kernel_config
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import _merge [as 别名]
#.........这里部分代码省略.........
else:
dpi_option = 'figure.dpi'
spy_cfg.InlineBackend.rc = {'figure.figsize': (6.0, 4.0),
dpi_option: 72,
'font.size': 10,
'figure.subplot.bottom': .125,
'figure.facecolor': 'white',
'figure.edgecolor': 'white'}
# Pylab configuration
mpl_backend = None
pylab_o = os.environ.get('SPY_PYLAB_O')
if pylab_o == 'True' and is_module_installed('matplotlib'):
# Set Matplotlib backend
backend_o = os.environ.get('SPY_BACKEND_O')
if backend_o is not None:
if backend_o == '1':
if is_module_installed('PyQt5'):
auto_backend = 'qt5'
elif is_module_installed('PyQt4'):
auto_backend = 'qt4'
elif is_module_installed('_tkinter'):
auto_backend = 'tk'
else:
auto_backend = 'inline'
else:
auto_backend = ''
backends = {'0': 'inline',
'1': auto_backend,
'2': 'qt5',
'3': 'qt4',
'4': 'osx',
'5': 'gtk3',
'6': 'gtk',
'7': 'wx',
'8': 'tk'}
mpl_backend = backends[backend_o]
# Automatically load Pylab and Numpy, or only set Matplotlib
# backend
autoload_pylab_o = os.environ.get('SPY_AUTOLOAD_PYLAB_O') == 'True'
command = "get_ipython().kernel._set_mpl_backend('{0}', {1})"
spy_cfg.IPKernelApp.exec_lines.append(
command.format(mpl_backend, autoload_pylab_o))
# Inline backend configuration
if mpl_backend == 'inline':
# Figure format
format_o = os.environ.get('SPY_FORMAT_O')
formats = {'0': 'png',
'1': 'svg'}
if format_o is not None:
spy_cfg.InlineBackend.figure_format = formats[format_o]
# Resolution
resolution_o = os.environ.get('SPY_RESOLUTION_O')
if resolution_o is not None:
spy_cfg.InlineBackend.rc[dpi_option] = float(resolution_o)
# Figure size
width_o = float(os.environ.get('SPY_WIDTH_O'))
height_o = float(os.environ.get('SPY_HEIGHT_O'))
if width_o is not None and height_o is not None:
spy_cfg.InlineBackend.rc['figure.figsize'] = (width_o,
height_o)
# Enable Cython magic
if is_module_installed('Cython'):
spy_cfg.IPKernelApp.exec_lines.append('%load_ext Cython')
# Run a file at startup
use_file_o = os.environ.get('SPY_USE_FILE_O')
run_file_o = os.environ.get('SPY_RUN_FILE_O')
if use_file_o == 'True' and run_file_o is not None:
spy_cfg.IPKernelApp.file_to_run = run_file_o
# Autocall
autocall_o = os.environ.get('SPY_AUTOCALL_O')
if autocall_o is not None:
spy_cfg.ZMQInteractiveShell.autocall = int(autocall_o)
# To handle the banner by ourselves in IPython 3+
spy_cfg.ZMQInteractiveShell.banner1 = ''
# Greedy completer
greedy_o = os.environ.get('SPY_GREEDY_O') == 'True'
spy_cfg.IPCompleter.greedy = greedy_o
# Sympy loading
sympy_o = os.environ.get('SPY_SYMPY_O') == 'True'
if sympy_o and is_module_installed('sympy'):
lines = sympy_config(mpl_backend)
spy_cfg.IPKernelApp.exec_lines.append(lines)
# Merge IPython and Spyder configs. Spyder prefs will have prevalence
# over IPython ones
cfg._merge(spy_cfg)
return cfg