2022-12-05 19:57:27 +01:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
|
|
from cpl_core.utils import String
|
|
|
|
|
|
|
|
|
|
|
|
class FileTemplateABC(ABC):
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def __init__(self, name: str, path: str, code: str):
|
|
|
|
self._name = f'{String.convert_to_snake_case(name)}.py'
|
|
|
|
self._path = path
|
|
|
|
self._code = code
|
|
|
|
|
2022-12-05 23:08:52 +01:00
|
|
|
def __repr__(self):
|
|
|
|
return f'<{type(self).__name__} {self._path}{self._name}>'
|
|
|
|
|
2022-12-05 19:57:27 +01:00
|
|
|
@property
|
|
|
|
def name(self) -> str:
|
|
|
|
return self._name
|
|
|
|
|
|
|
|
@property
|
|
|
|
def path(self) -> str:
|
|
|
|
return self._path
|
2022-12-05 23:08:52 +01:00
|
|
|
|
|
|
|
@path.setter
|
|
|
|
def path(self, value: str):
|
|
|
|
self._path = value
|
2022-12-05 19:57:27 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def value(self) -> str:
|
|
|
|
return self.get_code()
|
|
|
|
|
|
|
|
@abstractmethod
|
2022-12-05 23:08:52 +01:00
|
|
|
def get_code(self) -> str: pass
|