当前位置: 首页>>代码示例>>Python>>正文


Python FileLoader.get_file方法代码示例

本文整理汇总了Python中cfn_sphere.file_loader.FileLoader.get_file方法的典型用法代码示例。如果您正苦于以下问题:Python FileLoader.get_file方法的具体用法?Python FileLoader.get_file怎么用?Python FileLoader.get_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cfn_sphere.file_loader.FileLoader的用法示例。


在下文中一共展示了FileLoader.get_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: resolve_parameter_values

# 需要导入模块: from cfn_sphere.file_loader import FileLoader [as 别名]
# 或者: from cfn_sphere.file_loader.FileLoader import get_file [as 别名]
    def resolve_parameter_values(self, stack_name, stack_config, cli_parameters=None):
        resolved_parameters = {}
        stack_outputs = self.cfn.get_stacks_outputs()

        for key, value in stack_config.parameters.items():

            if isinstance(value, list):
                self.logger.debug("List parameter found for {0}".format(key))
                for i, item in enumerate(value):
                    if DependencyResolver.is_parameter_reference(item):
                        referenced_stack, output_name = DependencyResolver.parse_stack_reference_value(item)
                        value[i] = str(self.get_output_value(stack_outputs, referenced_stack, output_name))

                value_string = self.convert_list_to_string(value)
                resolved_parameters[key] = value_string

            elif isinstance(value, str):

                if DependencyResolver.is_parameter_reference(value):
                    referenced_stack, output_name = DependencyResolver.parse_stack_reference_value(value)
                    resolved_parameters[key] = str(self.get_output_value(stack_outputs, referenced_stack, output_name))

                elif self.is_keep_value(value):
                    resolved_parameters[key] = str(self.get_latest_value(key, value, stack_name))

                elif self.is_taupage_ami_reference(value):
                    resolved_parameters[key] = str(self.ec2.get_latest_taupage_image_id())

                elif self.is_kms(value):
                    resolved_parameters[key] = str(self.kms.decrypt(value.split('|', 2)[2]))

                elif self.is_file(value):
                    url = value.split('|', 2)[2]
                    resolved_parameters[key] = FileLoader.get_file(url, stack_config.working_dir)

                else:
                    resolved_parameters[key] = value

            elif isinstance(value, bool):
                resolved_parameters[key] = str(value).lower()
            elif isinstance(value, (int, float)):
                resolved_parameters[key] = str(value)
            else:
                raise NotImplementedError("Cannot handle {0} type for key: {1}".format(type(value), key))

        if cli_parameters:
            return self.update_parameters_with_cli_parameters(resolved_parameters, cli_parameters, stack_name)
        else:
            return resolved_parameters
开发者ID:cfn-sphere,项目名称:cfn-sphere,代码行数:51,代码来源:parameter_resolver.py

示例2: handle_file_value

# 需要导入模块: from cfn_sphere.file_loader import FileLoader [as 别名]
# 或者: from cfn_sphere.file_loader.FileLoader import get_file [as 别名]
    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>]")
开发者ID:matt-wormley,项目名称:cfn-sphere,代码行数:18,代码来源:parameter_resolver.py

示例3: test_get_file_calls_correct_handler_for_fs_path

# 需要导入模块: from cfn_sphere.file_loader import FileLoader [as 别名]
# 或者: from cfn_sphere.file_loader.FileLoader import get_file [as 别名]
 def test_get_file_calls_correct_handler_for_fs_path(self, fs_get_file_mock):
     FileLoader.get_file("foo/foo.yml", "/home/user")
     fs_get_file_mock.assert_called_with("foo/foo.yml", "/home/user")
开发者ID:gvsurenderreddy,项目名称:cfn-sphere,代码行数:5,代码来源:file_loader_tests.py

示例4: test_get_file_calls_correct_handler_for_S3_prefix

# 需要导入模块: from cfn_sphere.file_loader import FileLoader [as 别名]
# 或者: from cfn_sphere.file_loader.FileLoader import get_file [as 别名]
 def test_get_file_calls_correct_handler_for_S3_prefix(self, s3_get_file_mock):
     FileLoader.get_file("S3://foo/foo.yml", None)
     s3_get_file_mock.assert_called_with("S3://foo/foo.yml")
开发者ID:gvsurenderreddy,项目名称:cfn-sphere,代码行数:5,代码来源:file_loader_tests.py


注:本文中的cfn_sphere.file_loader.FileLoader.get_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。