# Path: makeapp/apptemplate.py
# class TemplateFile:
#     """Represents app template file info."""
# 
#     __slots__ = ['template', 'path_full', 'path_rel']
# 
#     def __init__(self, template: AppTemplate, path_full: str, path_rel: str):
#         """
#         :param template:
#         :param path_full:
#         :param path_rel:
# 
#         """
#         self.template = template
#         self.path_full = path_full
#         self.path_rel = path_rel
# 
#     def __str__(self):
#         return self.path_full
# 
#     @property
#     def parent_paths(self):
#         """A list of parent template paths."""
#         paths = []
# 
#         path_rel = self.path_rel
# 
#         parent = self.template
# 
#         while True:
#             parent = parent.parent
# 
#             if not parent:
#                 break
# 
#             path_full = os.path.join(parent.path, path_rel)
# 
#             if os.path.exists(path_full):
#                 # Check parent file exists in template.
#                 paths.append(os.path.join(parent.name, path_rel))
# 
#             if parent.is_default:
#                 break
# 
#         return paths
# 
# Path: makeapp/utils.py
# @contextmanager
# def chdir(target_path):
#     """Context manager.
#      
#     Temporarily switches the current working directory.
#     
#     """
#     curr_dir = os.getcwd()
#     os.chdir(target_path)
# 
#     try:
#         yield
# 
#     finally:
#         os.chdir(curr_dir)


import os
from typing import Union
from jinja2 import Environment, FileSystemLoader
from .apptemplate import TemplateFile
from .utils import chdir
    from .appmaker import AppMaker
            'python_version_major': context['python_version'].split('.')[0],
            'module_name_capital': context['module_name'].capitalize(),
        })

        return context


class Renderer:
    """Performs file rendering."""

    def __init__(self, maker, paths):
        self.context_mutator = ContextMutator(maker=maker)

        paths = list({}.fromkeys(paths).keys())  # Unique.
        paths.insert(0, '.')  # Use current working dir.

        self.env = Environment(
            loader=DynamicParentLoader(paths),
            keep_trailing_newline=True,
            trim_blocks=True,
        )

    def render(self, filename: Union[str, TemplateFile]) -> str:
        """Renders file contents with settings as get_context.

        :param filename:

        """
        context = self.context_mutator.get_context()


# Path: makeapp/apptemplate.py
# class TemplateFile:
#     """Represents app template file info."""
# 
#     __slots__ = ['template', 'path_full', 'path_rel']
# 
#     def __init__(self, template: AppTemplate, path_full: str, path_rel: str):
#         """
#         :param template:
#         :param path_full:
#         :param path_rel:
# 
#         """
#         self.template = template
#         self.path_full = path_full
#         self.path_rel = path_rel
# 
#     def __str__(self):
#         return self.path_full
# 
#     @property
#     def parent_paths(self):
#         """A list of parent template paths."""
#         paths = []
# 
#         path_rel = self.path_rel
# 
#         parent = self.template
# 
#         while True:
#             parent = parent.parent
# 
#             if not parent:
#                 break
# 
#             path_full = os.path.join(parent.path, path_rel)
# 
#             if os.path.exists(path_full):
#                 # Check parent file exists in template.
#                 paths.append(os.path.join(parent.name, path_rel))
# 
#             if parent.is_default:
#                 break
# 
#         return paths
# 
# Path: makeapp/utils.py
# @contextmanager
# def chdir(target_path):
#     """Context manager.
#      
#     Temporarily switches the current working directory.
#     
#     """
#     curr_dir = os.getcwd()
#     os.chdir(target_path)
# 
#     try:
#         yield
# 
#     finally:
#         os.chdir(curr_dir)


# Path: makeapp/rendering.py
import os
from typing import Union
from jinja2 import Environment, FileSystemLoader
from .apptemplate import TemplateFile
from .utils import chdir
    from .appmaker import AppMaker

            'python_version_major': context['python_version'].split('.')[0],
            'module_name_capital': context['module_name'].capitalize(),
        })

        return context


class Renderer:
    """Performs file rendering."""

    def __init__(self, maker, paths):
        self.context_mutator = ContextMutator(maker=maker)

        paths = list({}.fromkeys(paths).keys())  # Unique.
        paths.insert(0, '.')  # Use current working dir.

        self.env = Environment(
            loader=DynamicParentLoader(paths),
            keep_trailing_newline=True,
            trim_blocks=True,
        )

    def render(self, filename: Union[str, TemplateFile]) -> str:
        """Renders file contents with settings as get_context.

        :param filename:

        """
        context = self.context_mutator.get_context()


        if isinstance(filename, TemplateFile):