本文整理汇总了Python中spinnaker.yaml_util.YamlBindings.import_string方法的典型用法代码示例。如果您正苦于以下问题:Python YamlBindings.import_string方法的具体用法?Python YamlBindings.import_string怎么用?Python YamlBindings.import_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spinnaker.yaml_util.YamlBindings
的用法示例。
在下文中一共展示了YamlBindings.import_string方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bool
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import import_string [as 别名]
def test_bool(self):
bindings = YamlBindings()
bindings.import_string(
"root:\n - elem: true\n - elem: True\n - elem: false\n - elem: False\ncopy: ${root}")
self.assertEqual([{'elem': True}, {'elem': True}, {'elem': False}, {'elem': False}],
bindings.get('root'))
self.assertEqual(bindings.get('root'), bindings.get('copy'))
示例2: test_list
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import import_string [as 别名]
def test_list(self):
bindings = YamlBindings()
bindings.import_string(
"root:\n - elem: 'first'\n - elem: 2\n - elem: true\ncopy: ${root}")
self.assertEqual([{'elem': 'first'}, {'elem': 2}, {'elem': True}],
bindings.get('root'))
self.assertEqual(bindings.get('root'), bindings.get('copy'))
示例3: test_number
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import import_string [as 别名]
def test_number(self):
bindings = YamlBindings()
bindings.import_string(
"scalar: 123\nneg: -321\ndef: ${unkown:234}\nindirect: ${scalar}")
self.assertEqual(123, bindings.get('scalar'))
self.assertEqual(-321, bindings.get('neg'))
self.assertEqual(234, bindings.get('def'))
self.assertEqual(123, bindings.get('indirect'))
示例4: test_boolean
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import import_string [as 别名]
def test_boolean(self):
bindings = YamlBindings()
bindings.import_string(
"t: true\nf: false\ndef: ${unkown:true}\nindirect: ${f}")
self.assertEqual(True, bindings.get('t'))
self.assertEqual(False, bindings.get('f'))
self.assertEqual(True, bindings.get('def'))
self.assertEqual(False, bindings.get('indirect'))
示例5: test_load_string
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import import_string [as 别名]
def test_load_string(self):
yaml = """
a: A
b: 0
c:
- A
- B
d:
child:
grandchild: x
e:
"""
expect = {'a': 'A',
'b': 0,
'c': ['A','B'],
'd': {'child': {'grandchild': 'x'}},
'e': None}
bindings = YamlBindings()
bindings.import_string(yaml)
self.assertEqual(expect, bindings.map)
示例6: test_load_composite_value
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import import_string [as 别名]
def test_load_composite_value(self):
bindings = YamlBindings()
bindings.import_dict({'a': 'A', 'b':'B'})
bindings.import_string('test: ${a}/${b}')
print str(bindings.map)
self.assertEqual('A/B', bindings.get('test'))
示例7: test_concat_default
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import import_string [as 别名]
def test_concat_default(self):
bindings = YamlBindings()
bindings.import_string(
"mix: a.${s:TEST}")
self.assertEqual('a.TEST', bindings.get('mix'))
示例8: test_concat
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import import_string [as 别名]
def test_concat(self):
bindings = YamlBindings()
bindings.import_string(
"s: 'TEST'\nmix: a.${s}")
self.assertEqual('a.TEST', bindings.get('mix'))