本文整理汇总了Python中traitlets.config.loader.Config.merge方法的典型用法代码示例。如果您正苦于以下问题:Python Config.merge方法的具体用法?Python Config.merge怎么用?Python Config.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类traitlets.config.loader.Config
的用法示例。
在下文中一共展示了Config.merge方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fromdictmerge2
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import merge [as 别名]
def test_fromdictmerge2(self):
c1 = Config({'Foo' : {'baz' : 2}})
c2 = Config({'Foo' : {'bar' : 1}})
c1.merge(c2)
self.assertEqual(c1.Foo.__class__, Config)
self.assertEqual(c1.Foo.bar, 1)
self.assertEqual(c1.Foo.baz, 2)
self.assertNotIn('baz', c2.Foo)
示例2: test_fromdictmerge2
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import merge [as 别名]
def test_fromdictmerge2(self):
c1 = Config({"Foo": {"baz": 2}})
c2 = Config({"Foo": {"bar": 1}})
c1.merge(c2)
self.assertEqual(c1.Foo.__class__, Config)
self.assertEqual(c1.Foo.bar, 1)
self.assertEqual(c1.Foo.baz, 2)
self.assertNotIn("baz", c2.Foo)
示例3: test_merge_no_copies
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import merge [as 别名]
def test_merge_no_copies(self):
c = Config()
c2 = Config()
c2.Foo.trait = []
c.merge(c2)
c2.Foo.trait.append(1)
self.assertIs(c.Foo, c2.Foo)
self.assertEqual(c.Foo.trait, [1])
self.assertEqual(c2.Foo.trait, [1])
示例4: test_merge_doesnt_exist
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import merge [as 别名]
def test_merge_doesnt_exist(self):
c1 = Config()
c2 = Config()
c2.bar = 10
c2.Foo.bar = 10
c1.merge(c2)
self.assertEqual(c1.Foo.bar, 10)
self.assertEqual(c1.bar, 10)
c2.Bar.bar = 10
c1.merge(c2)
self.assertEqual(c1.Bar.bar, 10)
示例5: load_config_file
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import merge [as 别名]
def load_config_file(self, filename, path=None):
"""Load config files by filename and path."""
filename, ext = os.path.splitext(filename)
new_config = Config()
for config in self._load_config_files(filename, path=path, log=self.log,
raise_config_file_errors=self.raise_config_file_errors,
):
new_config.merge(config)
# add self.cli_config to preserve CLI config priority
new_config.merge(self.cli_config)
self.update_config(new_config)
示例6: test_merge_exists
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import merge [as 别名]
def test_merge_exists(self):
c1 = Config()
c2 = Config()
c1.Foo.bar = 10
c1.Foo.bam = 30
c2.Foo.bar = 20
c2.Foo.wow = 40
c1.merge(c2)
self.assertEqual(c1.Foo.bam, 30)
self.assertEqual(c1.Foo.bar, 20)
self.assertEqual(c1.Foo.wow, 40)
c2.Foo.Bam.bam = 10
c1.merge(c2)
self.assertEqual(c1.Foo.Bam.bam, 10)
示例7: test_fromdictmerge
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import merge [as 别名]
def test_fromdictmerge(self):
c1 = Config()
c2 = Config({'Foo' : {'bar' : 1}})
c1.merge(c2)
self.assertEqual(c1.Foo.__class__, Config)
self.assertEqual(c1.Foo.bar, 1)
示例8: print
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import merge [as 别名]
#
# 3. Update nbconvert configuration
#
json_config = os.path.join(jupyter_config_dir(), 'jupyter_nbconvert_config.json')
print("Configuring %s" % json_config)
if os.path.isfile(json_config) is True:
cl = JSONFileConfigLoader(json_config)
config = cl.load_config()
else:
config = Config()
newconfig = Config()
# Set template path, pre- and postprocessors of notebook extensions
newconfig.Exporter.template_path = [os.path.join(data_dir, 'templates')]
newconfig.Exporter.preprocessors = ["pre_codefolding.CodeFoldingPreprocessor", "pre_pymarkdown.PyMarkdownPreprocessor"]
newconfig.NbConvertApp.postprocessor_class = 'post_embedhtml.EmbedPostProcessor'
config.merge(newconfig)
config.version = 1
s=json.dumps(config, indent=2, separators=(',', ': '), sort_keys=True)
with open(json_config, 'w') as f:
f.write(s)
py_config = os.path.join(jupyter_config_dir(), 'jupyter_nbconvert_config.py')
print("Configuring %s" % py_config)
new_py_config = 'jupyter_nbconvert_config.py'
update_config(py_config, new_py_config)
#
# 4. Update notebook configuration
#
fname = os.path.join(config_dir, 'jupyter_notebook_config.json')
示例9: test_fromdictmerge
# 需要导入模块: from traitlets.config.loader import Config [as 别名]
# 或者: from traitlets.config.loader.Config import merge [as 别名]
def test_fromdictmerge(self):
c1 = Config()
c2 = Config({"Foo": {"bar": 1}})
c1.merge(c2)
self.assertEqual(c1.Foo.__class__, Config)
self.assertEqual(c1.Foo.bar, 1)