Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more efficient algorithm for getting applied templates with sources #132

Open
github-actions bot opened this issue May 29, 2022 · 0 comments
Open
Labels

Comments

@github-actions
Copy link
Contributor

more efficient algorithm for getting applied templates with sources

# TODO: more efficient algorithm for getting applied templates with sources

        config: Optional[FlexlateConfig] = None,
    ) -> List[AppliedTemplateWithSource]:
        config = config or self.load_config(project_root)

        # TODO: more efficient algorithm for getting applied templates with sources

        def get_source_config_path(source_name: str) -> Path:
            if config is None:
                raise ValueError("should not hit this, for type narrowing")
            for child_config in config.child_configs:
                for source in child_config.template_sources:
                    if source.name == source_name:
                        return child_config.settings.config_location
            raise ValueError(f"could not find source {source_name}")

        sources = config.template_sources_dict
        applied_template_with_sources: List[AppliedTemplateWithSource] = []

        for child_config in config.child_configs:
            for i, applied_template in enumerate(child_config.applied_templates):
                source = sources[applied_template.name]
                source_config_path = get_source_config_path(source.name)
                applied_template_config_path = child_config.settings.config_location
                if (
                    relative_to is not None
                    and source.git_url is None
                    and not Path(source.path).is_absolute()
                ):
                    new_path = (relative_to / Path(source.path)).resolve()
                    use_source = source.copy(update=dict(path=new_path))
                else:
                    use_source = source
                applied_template_with_sources.append(
                    AppliedTemplateWithSource(
                        applied_template=applied_template,
                        source=use_source,
                        index=i,
                        source_config_path=source_config_path,
                        applied_template_config_path=applied_template_config_path,
                    )
                )
        return applied_template_with_sources

    def get_all_renderables(

07b2332c4e8c75086847d35f9414aca5441cdd80

@github-actions github-actions bot added the todo label May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants