本文整理汇总了Python中cfn_sphere.file_loader.FileLoader类的典型用法代码示例。如果您正苦于以下问题:Python FileLoader类的具体用法?Python FileLoader怎么用?Python FileLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_template
def render_template(filename):
check_update_available()
loader = FileLoader()
template = loader.get_file_from_url(filename, None)
template = CloudFormationTemplateTransformer.transform_template(template)
click.echo(template.get_template_json())
示例2: render_template
def render_template(template_file, confirm):
if not confirm:
check_update_available()
loader = FileLoader()
template = loader.get_file_from_url(template_file, None)
template = CloudFormationTemplateTransformer.transform_template(template)
click.echo(template.get_pretty_template_json())
示例3: render_template
def render_template(template_file, confirm, yes):
confirm = confirm or yes
if not confirm:
check_update_available()
loader = FileLoader()
template = loader.get_cloudformation_template(template_file, None)
template = CloudFormationTemplateTransformer.transform_template(template)
click.echo(template.get_pretty_template_json())
示例4: test_handle_yaml_constructors_converts_ref
def test_handle_yaml_constructors_converts_ref(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = "myResource"
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!ref", node_mock)
self.assertEqual({'Ref': "myResource"}, response)
示例5: test_handle_yaml_constructors_converts_sub
def test_handle_yaml_constructors_converts_sub(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = ["string", {"key": "value"}]
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!sub", node_mock)
self.assertEqual({'Fn::Sub': ["string", {"key": "value"}]}, response)
示例6: test_handle_yaml_constructors_converts_select
def test_handle_yaml_constructors_converts_select(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = ["index", "list"]
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!select", node_mock)
self.assertEqual({'Fn::Select': ["index", "list"]}, response)
示例7: test_handle_yaml_constructors_converts_join
def test_handle_yaml_constructors_converts_join(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = ["delimiter", ["a", "b"]]
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!join", node_mock)
self.assertEqual({'Fn::Join': ["delimiter", ["a", "b"]]}, response)
示例8: test_handle_yaml_constructors_converts_import_value
def test_handle_yaml_constructors_converts_import_value(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = "sharedValue"
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!ImportValue", node_mock)
self.assertEqual({'Fn::ImportValue': "sharedValue"}, response)
示例9: test_handle_yaml_constructors_converts_get_azs
def test_handle_yaml_constructors_converts_get_azs(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = "region"
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!GetAZs", node_mock)
self.assertEqual({'Fn::GetAZs': "region"}, response)
示例10: test_handle_yaml_constructors_converts_getatt
def test_handle_yaml_constructors_converts_getatt(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = "logicalNameOfResource.attributeName"
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!GetAtt", node_mock)
self.assertEqual({'Fn::GetAtt': ["logicalNameOfResource", "attributeName"]}, response)
示例11: test_handle_yaml_constructors_converts_find_in_map
def test_handle_yaml_constructors_converts_find_in_map(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = ["MapName", "TopLevelKey", "SecondLevelKey"]
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!FindInMap", node_mock)
self.assertEqual({'Fn::FindInMap': ["MapName", "TopLevelKey", "SecondLevelKey"]}, response)
示例12: test_handle_yaml_constructors_converts_or
def test_handle_yaml_constructors_converts_or(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = ["myCondition", "myOtherCondition"]
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!or", node_mock)
self.assertEqual({'Fn::Or': ["myCondition", "myOtherCondition"]}, response)
示例13: test_handle_yaml_constructors_converts_equals
def test_handle_yaml_constructors_converts_equals(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = ["myValue", "myOtherValue"]
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!equals", node_mock)
self.assertEqual({'Fn::Equals': ["myValue", "myOtherValue"]}, response)
示例14: test_handle_yaml_constructors_converts_base64
def test_handle_yaml_constructors_converts_base64(self):
loader_mock = Mock()
loader_mock.construct_scalar.return_value = "myString"
node_mock = Mock(spec=yaml.ScalarNode)
response = FileLoader.handle_yaml_constructors(loader_mock, "!base64", node_mock)
self.assertEqual({'Fn::Base64': 'myString'}, response)
示例15: handle_file_value
def handle_file_value(value, working_dir):
components = value.split('|', 3)
if len(components) == 3:
url = components[2]
return FileLoader.get_file(url, working_dir)
elif len(components) == 4:
url = components[2]
pattern = components[3]
file_content = FileLoader.get_yaml_or_json_file(url, working_dir)
try:
return jmespath.search(pattern, file_content)
except JMESPathError as e:
raise CfnSphereException(e)
else:
raise CfnSphereException("Invalid format for |File| macro, it must be |File|<path>[|<pattern>]")