Coverage for src/kwai/core/template/template_engine.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2024-01-01 00:00 +0000

1"""Module that defines an interface for a template engine.""" 

2 

3from abc import abstractmethod 

4 

5from .template import Template 

6 

7 

8class TemplateNotFoundException(Exception): 

9 """Raised when a template cannot be found.""" 

10 

11 

12class TemplateEngine: 

13 """Interface for a template engine.""" 

14 

15 @abstractmethod 

16 def create(self, template_file_path: str) -> Template: 

17 """Create a template from the given file path. 

18 

19 When the template cannot be found, a TemplateNotFoundException should be raised. 

20 """ 

21 raise NotImplementedError