本文整理汇总了Python中IPython.config.loader.PyFileConfigLoader.load_config方法的典型用法代码示例。如果您正苦于以下问题:Python PyFileConfigLoader.load_config方法的具体用法?Python PyFileConfigLoader.load_config怎么用?Python PyFileConfigLoader.load_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.config.loader.PyFileConfigLoader
的用法示例。
在下文中一共展示了PyFileConfigLoader.load_config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_file_config
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def load_file_config(self, suppress_errors=True):
"""Load the config file.
This tries to load the config file from disk. If successful, the
``CONFIG_FILE`` config variable is set to the resolved config file
location. If not successful, an empty config is used.
By default, errors in loading config are handled, and a warning
printed on screen. For testing, the suppress_errors option is set
to False, so errors will make tests fail.
"""
self.log.debug("Attempting to load config file: %s" %
self.config_file_name)
loader = PyFileConfigLoader(self.config_file_name,
path=self.config_file_paths)
try:
self.file_config = loader.load_config()
self.file_config.Global.config_file = loader.full_filename
except IOError:
# Only warn if the default config file was NOT being used.
if not self.config_file_name==self.default_config_file_name:
self.log.warn("Config file not found, skipping: %s" %
self.config_file_name, exc_info=True)
self.file_config = Config()
except:
if not suppress_errors: # For testing purposes
raise
self.log.warn("Error loading config file: %s" %
self.config_file_name, exc_info=True)
self.file_config = Config()
示例2: test_profile
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def test_profile(profile_name,infile, reference_file):
loader = PyFileConfigLoader(profile_name+'.nbcv',path=[os.path.join(os.getcwdu(),'profile/')])
config = loader.load_config()
C = ConverterTemplate(config=config)
output,resources = C.from_filename(infile)
with io.open(reference_file,'r') as f:
compfiles(output,f.read())
示例3: get_config
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def get_config(profile_name='default'):
basefilename = 'nbx_config'
ipython_dir = get_ipython_dir()
profiledir = ProfileDir.find_profile_dir_by_name(ipython_dir, profile_name)
pyloader = PyFileConfigLoader(basefilename+'.py', path=profiledir.location)
config = pyloader.load_config()
return config
示例4: test_python
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def test_python(self):
fd, fname = mkstemp('.py')
f = os.fdopen(fd, 'w')
f.write(pyfile)
f.close()
# Unlink the file
cl = PyFileConfigLoader(fname, log=log)
config = cl.load_config()
self._check_conf(config)
示例5: load_config
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def load_config(self, config_file):
cfg = PyFileConfigLoader(config_file)
cfg.load_config()
self.config = cfg.config
# special casing for SAMPLE_GENERATED
if self.config.trigger == "SAMPLE_GENERATED":
self.config.trigger_msg = rc.MT_SAMPLE_GENERATED
self.config.trigger_mdf = rc.MDF_SAMPLE_GENERATED
else:
self.config.trigger_msg = eval("rc.MT_" + self.config.trigger)
self.config.trigger_mdf = eval("rc.MDF_" + self.config.trigger)
print "Triggering with", self.config.trigger
print "PolarisDragonfly: loading config"
# self.ntools = len(self.config.tool_list)
self.plate = self.config.tools.index("CB609")
self.marker = self.config.tools.index("CT315")
示例6: load_default_config
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def load_default_config(ipython_dir=None):
"""Load the default config file from the default ipython_dir.
This is useful for embedded shells.
"""
if ipython_dir is None:
ipython_dir = get_ipython_dir()
cl = PyFileConfigLoader(default_config_file_name, ipython_dir)
config = cl.load_config()
return config
示例7: load_config_file
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def load_config_file(self, filename):
"""Load a config file from the top level of the cluster dir.
Parameters
----------
filename : unicode or str
The filename only of the config file that must be located in
the top-level of the cluster directory.
"""
loader = PyFileConfigLoader(filename, self.location)
return loader.load_config()
示例8: config_ipw
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def config_ipw(ipw):
"""Apply and then modify default settings of IPython Qt widget"""
ipython_dir = get_ipython_dir()
profile_dir = os.path.join(ipython_dir, 'profile_default')
cl = PyFileConfigLoader('ipython_qtconsole_config.py', profile_dir)
config = cl.load_config()
ipw.config = config
ipw.set_default_style(colors='Linux')
ipw.font = QFont('Lucida Console', 11) # 3rd arg can be e.g. QFont.Bold
ipw.font.setFixedPitch(True)
示例9: test_basic
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def test_basic(self):
fd, fname = mkstemp('.py')
f = os.fdopen(fd, 'w')
f.write(pyfile)
f.close()
# Unlink the file
cl = PyFileConfigLoader(fname)
config = cl.load_config()
self.assertEqual(config.a, 10)
self.assertEqual(config.b, 20)
self.assertEqual(config.Foo.Bar.value, 10)
self.assertEqual(config.Foo.Bam.value, range(10))
self.assertEqual(config.D.C.value, 'hi there')
示例10: load_config_file
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def load_config_file(self, filename, path=None):
"""Load a .py based config file by filename and path."""
loader = PyFileConfigLoader(filename, path=path)
try:
config = loader.load_config()
except IOError:
# problem with the file (probably doesn't exist), raise
raise
except Exception:
# problem while running the file
self.log.error("Exception while loading config file %s [path=%s]"%
(filename, path), exc_info=True)
else:
self.update_config(config)
示例11: load_default_config
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def load_default_config(ipython_dir=None):
"""Load the default config file from the default ipython_dir.
This is useful for embedded shells.
"""
if ipython_dir is None:
ipython_dir = get_ipython_dir()
profile_dir = os.path.join(ipython_dir, 'profile_default')
cl = PyFileConfigLoader(default_config_file_name, profile_dir)
try:
config = cl.load_config()
except ConfigFileNotFound:
# no config found
config = Config()
return config
示例12: load_config_file
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def load_config_file(self, filename, path=None):
"""Load a .py based config file by filename and path."""
loader = PyFileConfigLoader(filename, path=path)
try:
config = loader.load_config()
except ConfigFileNotFound:
# problem finding the file, raise
raise
except Exception:
# try to get the full filename, but it will be empty in the
# unlikely event that the error raised before filefind finished
filename = loader.full_filename or filename
# problem while running the file
self.log.error("Exception while loading config file %s", filename, exc_info=True)
else:
self.log.debug("Loaded config file: %s", loader.full_filename)
self.update_config(config)
示例13: load_config_file
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def load_config_file(self, *args, **kwds):
from IPython.config.loader import PyFileConfigLoader, ConfigFileNotFound
from IPython.core.profiledir import ProfileDir
from IPython.utils.path import get_ipython_dir
conf = Config()
conf._merge(DEFAULT_SAGE_CONFIG)
conf._merge(self.command_line_config)
# Get user config.
sage_profile_dir = ProfileDir.find_profile_dir_by_name(
get_ipython_dir(), 'sage').location
try:
cl = PyFileConfigLoader('ipython_config.py', sage_profile_dir)
conf._merge(cl.load_config())
except ConfigFileNotFound:
pass
self.update_config(conf)
示例14: load_file_config
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def load_file_config(self):
"""Load the config file.
This tries to load the config file from disk. If successful, the
``CONFIG_FILE`` config variable is set to the resolved config file
location. If not successful, an empty config is used.
"""
self.log.debug("Attempting to load config file: %s" %
self.config_file_name)
loader = PyFileConfigLoader(self.config_file_name,
path=self.config_file_paths)
try:
self.file_config = loader.load_config()
self.file_config.Global.config_file = loader.full_filename
except IOError:
# Only warn if the default config file was NOT being used.
if not self.config_file_name==self.default_config_file_name:
self.log.warn("Config file not found, skipping: %s" %
self.config_file_name, exc_info=True)
self.file_config = Config()
except:
self.log.warn("Error loading config file: %s" %
self.config_file_name, exc_info=True)
self.file_config = Config()
示例15: check_null_profile
# 需要导入模块: from IPython.config.loader import PyFileConfigLoader [as 别名]
# 或者: from IPython.config.loader.PyFileConfigLoader import load_config [as 别名]
def check_null_profile(profile):
loader = PyFileConfigLoader(profile, path=[os.path.join(os.getcwdu(),'profile/test')])
config = loader.load_config()
C = ConverterTemplate(config=config)
result,_ = C.from_filename('tests/ipynbref/IntroNumPy.orig.ipynb')
nt.assert_equal(result.strip('\n'),'')