mirror of
https://github.com/dtomlinson91/tembo.git
synced 2025-12-22 11:55:45 +00:00
adding latest
This commit is contained in:
@@ -1,19 +1,37 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
from tembo.exceptions import BasePathDoesNotExistError # noqa
|
||||||
|
from tembo import logger
|
||||||
|
|
||||||
|
|
||||||
class PageCreator:
|
class PageCreator:
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def create_page(self, path, user_input, raw_entry_input) -> Page:
|
def create_page(self, base_path: str, page_path: str, user_input: str) -> Page:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _convert_to_path(base_path: str, page_path: str) -> pathlib.Path:
|
||||||
|
if not pathlib.Path(base_path).expanduser().exists():
|
||||||
|
logger.debug("base path of %s does not exist", base_path, exec_info=1)
|
||||||
|
raise BasePathDoesNotExistError(
|
||||||
|
f"Your base path of {base_path} does not exist."
|
||||||
|
)
|
||||||
|
return pathlib.Path(base_path).expanduser() / pathlib.Path(page_path)
|
||||||
|
|
||||||
|
|
||||||
class ScopedPageCreator(PageCreator):
|
class ScopedPageCreator(PageCreator):
|
||||||
|
def __init__(self, raw_entry_input: str) -> None:
|
||||||
|
self.raw_entry_input = raw_entry_input
|
||||||
|
|
||||||
def create_page(
|
def create_page(
|
||||||
self, path: str, user_input, raw_entry_input: dict | None = None
|
self, base_path: str, page_path: str, user_input: str | None
|
||||||
) -> Page:
|
) -> Page:
|
||||||
pass
|
path = self._convert_to_path(base_path, page_path)
|
||||||
|
# substitute tokens in path
|
||||||
|
# substitute tokens in raw_entry_input
|
||||||
|
|
||||||
|
|
||||||
class Page(metaclass=ABCMeta):
|
class Page(metaclass=ABCMeta):
|
||||||
|
|||||||
Reference in New Issue
Block a user