2021-03-30 12:44:31 +02:00
|
|
|
import os
|
|
|
|
|
2021-04-14 10:58:47 +02:00
|
|
|
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
2021-03-30 12:44:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TemplateBuilder:
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def build(project_path: str, template: TemplateFileABC):
|
|
|
|
"""
|
|
|
|
Creates template
|
|
|
|
:param project_path:
|
|
|
|
:param template:
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
file_path = os.path.join(project_path, template.path, template.name)
|
|
|
|
file_rel_path = os.path.join(project_path, template.path)
|
|
|
|
|
|
|
|
if not os.path.isdir(file_rel_path):
|
|
|
|
os.makedirs(file_rel_path)
|
|
|
|
|
2021-05-19 08:01:02 +02:00
|
|
|
with open(file_path, 'w') as file:
|
|
|
|
file.write(template.value)
|
|
|
|
file.close()
|