mirror of
https://github.com/dtomlinson91/tembo.git
synced 2025-12-22 09:35:44 +00:00
adding latest
This commit is contained in:
@@ -13,6 +13,7 @@ Documentation:
|
|||||||
☐ Document using `__main__.py` and `cli.py`
|
☐ Document using `__main__.py` and `cli.py`
|
||||||
Use Duty as an example
|
Use Duty as an example
|
||||||
|
|
||||||
|
☐ Document regex usage
|
||||||
☐ Write documentation using `mkdocs`
|
☐ Write documentation using `mkdocs`
|
||||||
☐ Look at how to use github actions
|
☐ Look at how to use github actions
|
||||||
Use <https://github.com/pdm-project/pdm/tree/main/.github/workflows> for an example
|
Use <https://github.com/pdm-project/pdm/tree/main/.github/workflows> for an example
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class PageCreatorOptions:
|
|||||||
|
|
||||||
|
|
||||||
class PageCreator:
|
class PageCreator:
|
||||||
|
@abstractmethod
|
||||||
def __init__(self, options: PageCreatorOptions) -> None:
|
def __init__(self, options: PageCreatorOptions) -> None:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ class PageCreator:
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def create_page(self, options: PageCreatorOptions) -> Page:
|
def create_page(self) -> Page:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def _check_base_path_exists(self) -> None:
|
def _check_base_path_exists(self) -> None:
|
||||||
@@ -111,16 +112,15 @@ class ScopedPageCreator(PageCreator):
|
|||||||
extension (str): extension of file.
|
extension (str): extension of file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self, options: PageCreatorOptions) -> None:
|
||||||
self._all_input_tokens: list[str] = []
|
self._all_input_tokens: list[str] = []
|
||||||
self._options: PageCreatorOptions
|
self._options = options
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def options(self) -> PageCreatorOptions:
|
def options(self) -> PageCreatorOptions:
|
||||||
return self._options
|
return self._options
|
||||||
|
|
||||||
def create_page(self, options: PageCreatorOptions) -> Page:
|
def create_page(self) -> Page:
|
||||||
self._options = options
|
|
||||||
self._check_base_path_exists()
|
self._check_base_path_exists()
|
||||||
|
|
||||||
self._all_input_tokens = self._get_input_tokens()
|
self._all_input_tokens = self._get_input_tokens()
|
||||||
@@ -130,7 +130,7 @@ class ScopedPageCreator(PageCreator):
|
|||||||
path = pathlib.Path(self._substitute_tokens(str(path)))
|
path = pathlib.Path(self._substitute_tokens(str(path)))
|
||||||
|
|
||||||
template_contents = self._load_template()
|
template_contents = self._load_template()
|
||||||
if options.template_filename is not None:
|
if self.options.template_filename is not None:
|
||||||
template_contents = self._substitute_tokens(template_contents)
|
template_contents = self._substitute_tokens(template_contents)
|
||||||
|
|
||||||
return ScopedPage(path, template_contents)
|
return ScopedPage(path, template_contents)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ def test_create_page_base_path_does_not_exist(tmpdir):
|
|||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
exceptions.BasePathDoesNotExistError
|
exceptions.BasePathDoesNotExistError
|
||||||
) as base_path_does_not_exist_error:
|
) as base_path_does_not_exist_error:
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
assert (
|
assert (
|
||||||
@@ -57,7 +57,7 @@ def test_create_page_template_file_does_not_exist(template_path, tmpdir):
|
|||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
exceptions.TemplateFileNotFoundError
|
exceptions.TemplateFileNotFoundError
|
||||||
) as template_file_not_found_error:
|
) as template_file_not_found_error:
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
if template_path is None:
|
if template_path is None:
|
||||||
@@ -88,7 +88,7 @@ def test_create_page_already_exists(datadir):
|
|||||||
).with_suffix(f".{options.extension}")
|
).with_suffix(f".{options.extension}")
|
||||||
|
|
||||||
# act
|
# act
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
with pytest.raises(exceptions.ScopedPageAlreadyExists) as page_already_exists:
|
with pytest.raises(exceptions.ScopedPageAlreadyExists) as page_already_exists:
|
||||||
scoped_page.save_to_disk()
|
scoped_page.save_to_disk()
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ def test_create_page_without_template(tmpdir, caplog):
|
|||||||
).with_suffix(f".{options.extension}")
|
).with_suffix(f".{options.extension}")
|
||||||
|
|
||||||
# act
|
# act
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
scoped_page.save_to_disk()
|
scoped_page.save_to_disk()
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
@@ -146,7 +146,7 @@ def test_create_page_with_template(datadir, caplog):
|
|||||||
).with_suffix(f".{options.extension}")
|
).with_suffix(f".{options.extension}")
|
||||||
|
|
||||||
# act
|
# act
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
scoped_page.save_to_disk()
|
scoped_page.save_to_disk()
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
@@ -192,7 +192,7 @@ def test_create_tokened_page_tokens_in_template(
|
|||||||
).with_suffix(f".{options.extension}")
|
).with_suffix(f".{options.extension}")
|
||||||
|
|
||||||
# act
|
# act
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
scoped_page.save_to_disk()
|
scoped_page.save_to_disk()
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
@@ -235,7 +235,7 @@ def test_create_tokened_page_tokens_in_filename(
|
|||||||
).with_suffix(f".{options.extension}")
|
).with_suffix(f".{options.extension}")
|
||||||
|
|
||||||
# act
|
# act
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
scoped_page.save_to_disk()
|
scoped_page.save_to_disk()
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
@@ -262,7 +262,7 @@ def test_create_tokened_page_input_tokens_preserve_order(datadir, caplog):
|
|||||||
).with_suffix(f".{options.extension}")
|
).with_suffix(f".{options.extension}")
|
||||||
|
|
||||||
# act
|
# act
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
scoped_page.save_to_disk()
|
scoped_page.save_to_disk()
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
@@ -292,7 +292,7 @@ def test_create_page_spaces_in_path(tmpdir, caplog):
|
|||||||
).with_suffix(f".{options.extension}")
|
).with_suffix(f".{options.extension}")
|
||||||
|
|
||||||
# act
|
# act
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
scoped_page.save_to_disk()
|
scoped_page.save_to_disk()
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
@@ -318,7 +318,7 @@ def test_create_page_dot_in_extension(tmpdir, caplog):
|
|||||||
).with_suffix(f".{options.extension[1:]}")
|
).with_suffix(f".{options.extension[1:]}")
|
||||||
|
|
||||||
# act
|
# act
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
scoped_page.save_to_disk()
|
scoped_page.save_to_disk()
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
@@ -344,7 +344,7 @@ def test_create_page_str_representation(tmpdir):
|
|||||||
).with_suffix(f".{options.extension}")
|
).with_suffix(f".{options.extension}")
|
||||||
|
|
||||||
# act
|
# act
|
||||||
scoped_page = ScopedPageCreator().create_page(options)
|
scoped_page = ScopedPageCreator(options).create_page()
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
assert str(scoped_page) == f"ScopedPage({scoped_page_file})"
|
assert str(scoped_page) == f"ScopedPage({scoped_page_file})"
|
||||||
|
|||||||
Reference in New Issue
Block a user