def evaluate_string()

in taskcat/_cfn/stack_url_helper.py [0:0]


    def evaluate_string(self, template_url, depth=0):
        """Recursively find expressions in the URL and send them to be evaluated"""
        # Recursion bail out
        if depth > self.MAX_DEPTH:
            raise Exception(
                "Template URL contains more than {} levels or nesting".format(
                    self.MAX_DEPTH
                )
            )

        template_urls = []
        # Evaluate expressions
        if "{" in template_url:
            parts = template_url.split("{")
            parts = parts[-1].split("}")  # Last open bracket

            # This function will handle Fn::Sub Fn::If etc.
            replacements = self.evaluate_expression_controller(
                parts[0]
            )  # First closed bracket after

            for replacement in replacements:
                template_url_temp = template_url
                template_url_temp = template_url_temp.replace(
                    "{" + parts[0] + "}", replacement
                )

                evaluated_strings = self.evaluate_string(
                    template_url_temp, depth=(depth + 1)
                )
                for evaluated_string in evaluated_strings:
                    template_urls.append(evaluated_string)
        else:
            template_urls.append(template_url)

        return template_urls