1 Commits

Author SHA1 Message Date
Daniel Tomlinson
db611e3d85 chore: release v1.0.0
chore: release v1.0.0
2021-12-26 19:56:08 +00:00
15 changed files with 283 additions and 296 deletions

10
.coveragerc Normal file
View File

@@ -0,0 +1,10 @@
[report]
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain if tests don't hit defensive assertion code:
raise NotImplementedError
[run]
source=tembo

View File

@@ -1,4 +1,4 @@
name: build
name: analysis
on:
push:

View File

@@ -8,15 +8,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- marker -->
## [v1.0.0](https://github.com/tembo-pages/tembo-core/commits/v1.0.0) - 2021-12-26
### ✨ Features
- Initial commit ([fb7fec](https://github.com/tembo-pages/tembo-core/commit/fb7fec7ea619318b0e0830c0f9260335c0d4e173))
### 📘 Documentation
### Documentation
- Update license documentation ([fad505](https://github.com/tembo-pages/tembo-core/commit/fad5054c378b304051bf91fc83fe91005bda34cc))
### 🧱 Build
### Features
- Initial commit ([fb7fec](https://github.com/tembo-pages/tembo-core/commit/fb7fec7ea619318b0e0830c0f9260335c0d4e173))
### Build
- Update panaetius to 2.3.2 ([737d24](https://github.com/tembo-pages/tembo-core/commit/737d2487d898195a9592de7856d38c6ce3423a20))
- Update dependencies to latest versions ([f5cfa0](https://github.com/tembo-pages/tembo-core/commit/f5cfa0201510c3623e2aa7c872fb81579d053558))

View File

@@ -7,11 +7,12 @@
A simple folder organiser for your work notes.
![](https://img.shields.io/codecov/c/github/tembo-pages/tembo-core?style=flat-square)
![Sonar Coverage](https://img.shields.io/sonar/coverage/tembo-pages_tembo-core?server=https%3A%2F%2Fsonarcloud.io&style=flat-square)
![Sonar Tests](https://img.shields.io/sonar/tests/tembo-pages_tembo-core?compact_message&failed_label=failed&passed_label=passed&server=https%3A%2F%2Fsonarcloud.io&skipped_label=skipped&style=flat-square)
![Sonar Tech Debt](https://img.shields.io/sonar/tech_debt/tembo-pages_tembo-core?server=https%3A%2F%2Fsonarcloud.io&style=flat-square)
Read the documentation here: <https://tembo-pages.github.io/tembo-core/>.
## config.yml
```yaml

View File

@@ -38,17 +38,16 @@ footer = """
conventional_commits = true
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "Features"},
{ message = "^fix", group = "🐛 Bug Fixes"},
{ message = "^doc", group = "📘 Documentation"},
{ message = "^perf", group = "🏎 Performance"},
{ message = "^refactor", group = "🛠 Refactor/Improvement"},
{ message = "^style", group = "🎨 Styling"},
{ message = "^test", group = "🧪 Testing"},
{ message = "^build", group = "🧱 Build"},
{ body = ".*security", group = "🔐 Security"},
{ message = "^feat", group = "Features"},
{ message = "^fix", group = "Bug Fixes"},
{ message = "^doc", group = "Documentation"},
{ message = "^perf", group = "Performance"},
{ message = "^refactor", group = "Refactor"},
{ message = "^style", group = "Styling"},
{ message = "^test", group = "Testing"},
{ message = "^chore\\(release\\): prepare for", skip = true},
{ message = "^chore", group = "🥱 Miscellaneous Tasks", skip = true},
{ message = "^chore", group = "Miscellaneous Tasks", skip = true},
{ body = ".*security", group = "Security"},
]
# filter out the commits that are not matched by commit parsers
filter_commits = false

View File

@@ -345,7 +345,7 @@ def changelog(ctx, planned_release: Optional[str] = None, previous_release: Opti
1,
f"<small>[Compare with {previous_release}]({REPO_URL}/compare/{previous_release}..{planned_release})</small>",
)
generated_changelog: str = "\n".join(list(generated_changelog)) + "\n"
generated_changelog: str = "\n".join([line for line in generated_changelog]) + "\n"
new_changelog = []
changelog_file = pathlib.Path(".") / "CHANGELOG.md"

96
poetry.lock generated
View File

@@ -23,11 +23,11 @@ tests = ["tox (>=2.6.0)", "pytest (>=3.0.3)", "pytest-cov (>=2.3.1)"]
[[package]]
name = "astroid"
version = "2.9.2"
version = "2.9.0"
description = "An abstract syntax tree for Python with inference support."
category = "dev"
optional = false
python-versions = ">=3.6.2"
python-versions = "~=3.6"
[package.dependencies]
lazy-object-proxy = ">=1.4.0"
@@ -55,17 +55,17 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "attrs"
version = "21.4.0"
version = "21.2.0"
description = "Classes Without Boilerplate"
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[package.extras]
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"]
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit"]
docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"]
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"]
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"]
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface"]
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins"]
[[package]]
name = "bandit"
@@ -91,7 +91,7 @@ python-versions = "*"
[[package]]
name = "charset-normalizer"
version = "2.0.10"
version = "2.0.9"
description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
category = "dev"
optional = false
@@ -252,7 +252,7 @@ smmap = ">=3.0.1,<6"
[[package]]
name = "gitpython"
version = "3.1.25"
version = "3.1.24"
description = "GitPython is a python library used to interact with Git repositories"
category = "dev"
optional = false
@@ -260,6 +260,7 @@ python-versions = ">=3.7"
[package.dependencies]
gitdb = ">=4.0.1,<5"
typing-extensions = {version = ">=3.7.4.3", markers = "python_version < \"3.10\""}
[[package]]
name = "idna"
@@ -403,11 +404,11 @@ i18n = ["babel (>=2.9.0)"]
[[package]]
name = "mkdocs-autorefs"
version = "0.3.1"
version = "0.3.0"
description = "Automatically link across pages in MkDocs."
category = "dev"
optional = false
python-versions = ">=3.6.2,<4.0.0"
python-versions = ">=3.6,<4.0"
[package.dependencies]
Markdown = ">=3.3,<4.0"
@@ -537,7 +538,7 @@ pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
[[package]]
name = "panaetius"
version = "2.3.4"
version = "2.3.3"
description = "Python module to gracefully handle a .config file/environment variables for scripts, with built in masking for sensitive options. Provides a Splunk friendly formatted logger instance."
category = "main"
optional = false
@@ -704,7 +705,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "pygments"
version = "2.11.2"
version = "2.10.0"
description = "Pygments is a syntax highlighting package written in Python."
category = "dev"
optional = false
@@ -731,7 +732,7 @@ hook_testing = ["pytest (>=2.7.3)", "execnet (>=1.5.0)", "psutil"]
[[package]]
name = "pyinstaller-hooks-contrib"
version = "2021.5"
version = "2021.4"
description = "Community maintained hooks for PyInstaller"
category = "dev"
optional = false
@@ -947,7 +948,7 @@ pyyaml = "*"
[[package]]
name = "requests"
version = "2.27.1"
version = "2.26.0"
description = "Python HTTP for Humans."
category = "dev"
optional = false
@@ -1068,7 +1069,7 @@ python-versions = ">=3.6"
[[package]]
name = "urllib3"
version = "1.26.8"
version = "1.26.7"
description = "HTTP library with thread-safe connection pooling, file post, and more."
category = "dev"
optional = false
@@ -1100,15 +1101,15 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
[[package]]
name = "zipp"
version = "3.7.0"
version = "3.6.0"
description = "Backport of pathlib-compatible object wrapper for zip files"
category = "dev"
optional = false
python-versions = ">=3.7"
python-versions = ">=3.6"
[package.extras]
docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"]
testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"]
testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"]
[metadata]
lock-version = "1.1"
@@ -1125,8 +1126,8 @@ ansimarkup = [
{file = "ansimarkup-1.5.0.tar.gz", hash = "sha256:96c65d75bbed07d3dcbda8dbede8c2252c984f90d0ca07434b88a6bbf345fad3"},
]
astroid = [
{file = "astroid-2.9.2-py3-none-any.whl", hash = "sha256:aa296702f1a5c3102c860de49473aaa90a7f6d221555d5cf2678940a9be32a4e"},
{file = "astroid-2.9.2.tar.gz", hash = "sha256:72ace9c3333e274e9248168fc4f3e300da8545af1c303bd69197027f49e2bfff"},
{file = "astroid-2.9.0-py3-none-any.whl", hash = "sha256:776ca0b748b4ad69c00bfe0fff38fa2d21c338e12c84aa9715ee0d473c422778"},
{file = "astroid-2.9.0.tar.gz", hash = "sha256:5939cf55de24b92bda00345d4d0659d01b3c7dafb5055165c330bc7c568ba273"},
]
astunparse = [
{file = "astunparse-1.6.3-py2.py3-none-any.whl", hash = "sha256:c2652417f2c8b5bb325c885ae329bdf3f86424075c4fd1a128674bc6fba4b8e8"},
@@ -1137,8 +1138,8 @@ atomicwrites = [
{file = "atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"},
]
attrs = [
{file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"},
{file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"},
{file = "attrs-21.2.0-py2.py3-none-any.whl", hash = "sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1"},
{file = "attrs-21.2.0.tar.gz", hash = "sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"},
]
bandit = [
{file = "bandit-1.7.1-py3-none-any.whl", hash = "sha256:f5acd838e59c038a159b5c621cf0f8270b279e884eadd7b782d7491c02add0d4"},
@@ -1149,8 +1150,8 @@ certifi = [
{file = "certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"},
]
charset-normalizer = [
{file = "charset-normalizer-2.0.10.tar.gz", hash = "sha256:876d180e9d7432c5d1dfd4c5d26b72f099d503e8fcc0feb7532c9289be60fcbd"},
{file = "charset_normalizer-2.0.10-py3-none-any.whl", hash = "sha256:cb957888737fc0bbcd78e3df769addb41fd1ff8cf950dc9e7ad7793f1bf44455"},
{file = "charset-normalizer-2.0.9.tar.gz", hash = "sha256:b0b883e8e874edfdece9c28f314e3dd5badf067342e42fb162203335ae61aa2c"},
{file = "charset_normalizer-2.0.9-py3-none-any.whl", hash = "sha256:1eecaa09422db5be9e29d7fc65664e6c33bd06f9ced7838578ba40d58bdf3721"},
]
click = [
{file = "click-8.0.3-py3-none-any.whl", hash = "sha256:353f466495adaeb40b6b5f592f9f91cb22372351c84caeb068132442a4518ef3"},
@@ -1249,8 +1250,8 @@ gitdb = [
{file = "gitdb-4.0.9.tar.gz", hash = "sha256:bac2fd45c0a1c9cf619e63a90d62bdc63892ef92387424b855792a6cabe789aa"},
]
gitpython = [
{file = "GitPython-3.1.25-py3-none-any.whl", hash = "sha256:4f8b0e51713642b83f1eb10136d36a7f2c5278d188c5ae82b144cb1f4e848f0c"},
{file = "GitPython-3.1.25.tar.gz", hash = "sha256:b923e8952c2fe0d70b129fddd8511acc90b3070c8dddb20d86ca9911a5d0c248"},
{file = "GitPython-3.1.24-py3-none-any.whl", hash = "sha256:dc0a7f2f697657acc8d7f89033e8b1ea94dd90356b2983bca89dc8d2ab3cc647"},
{file = "GitPython-3.1.24.tar.gz", hash = "sha256:df83fdf5e684fef7c6ee2c02fc68a5ceb7e7e759d08b694088d0cacb4eba59e5"},
]
idna = [
{file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"},
@@ -1325,9 +1326,6 @@ markupsafe = [
{file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad"},
{file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d"},
{file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646"},
{file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4dc8f9fb58f7364b63fd9f85013b780ef83c11857ae79f2feda41e270468dd9b"},
{file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:20dca64a3ef2d6e4d5d615a3fd418ad3bde77a47ec8a23d984a12b5b4c74491a"},
{file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:cdfba22ea2f0029c9261a4bd07e830a8da012291fbe44dc794e488b6c9bb353a"},
{file = "MarkupSafe-2.0.1-cp310-cp310-win32.whl", hash = "sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28"},
{file = "MarkupSafe-2.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134"},
{file = "MarkupSafe-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51"},
@@ -1339,9 +1337,6 @@ markupsafe = [
{file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c"},
{file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724"},
{file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145"},
{file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:deb993cacb280823246a026e3b2d81c493c53de6acfd5e6bfe31ab3402bb37dd"},
{file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:63f3268ba69ace99cab4e3e3b5840b03340efed0948ab8f78d2fd87ee5442a4f"},
{file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:8d206346619592c6200148b01a2142798c989edcb9c896f9ac9722a99d4e77e6"},
{file = "MarkupSafe-2.0.1-cp36-cp36m-win32.whl", hash = "sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d"},
{file = "MarkupSafe-2.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9"},
{file = "MarkupSafe-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567"},
@@ -1353,9 +1348,6 @@ markupsafe = [
{file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85"},
{file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6"},
{file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864"},
{file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d6c7ebd4e944c85e2c3421e612a7057a2f48d478d79e61800d81468a8d842207"},
{file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:f0567c4dc99f264f49fe27da5f735f414c4e7e7dd850cfd8e69f0862d7c74ea9"},
{file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:89c687013cb1cd489a0f0ac24febe8c7a666e6e221b783e53ac50ebf68e45d86"},
{file = "MarkupSafe-2.0.1-cp37-cp37m-win32.whl", hash = "sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415"},
{file = "MarkupSafe-2.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914"},
{file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9"},
@@ -1368,9 +1360,6 @@ markupsafe = [
{file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b"},
{file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a"},
{file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6"},
{file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:aca6377c0cb8a8253e493c6b451565ac77e98c2951c45f913e0b52facdcff83f"},
{file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:04635854b943835a6ea959e948d19dcd311762c5c0c6e1f0e16ee57022669194"},
{file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6300b8454aa6930a24b9618fbb54b5a68135092bc666f7b06901f897fa5c2fee"},
{file = "MarkupSafe-2.0.1-cp38-cp38-win32.whl", hash = "sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64"},
{file = "MarkupSafe-2.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833"},
{file = "MarkupSafe-2.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26"},
@@ -1383,9 +1372,6 @@ markupsafe = [
{file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1"},
{file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac"},
{file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6"},
{file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4296f2b1ce8c86a6aea78613c34bb1a672ea0e3de9c6ba08a960efe0b0a09047"},
{file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f02365d4e99430a12647f09b6cc8bab61a6564363f313126f775eb4f6ef798e"},
{file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5b6d930f030f8ed98e3e6c98ffa0652bdb82601e7a016ec2ab5d7ff23baa78d1"},
{file = "MarkupSafe-2.0.1-cp39-cp39-win32.whl", hash = "sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74"},
{file = "MarkupSafe-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8"},
{file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"},
@@ -1403,8 +1389,8 @@ mkdocs = [
{file = "mkdocs-1.2.3.tar.gz", hash = "sha256:89f5a094764381cda656af4298727c9f53dc3e602983087e1fe96ea1df24f4c1"},
]
mkdocs-autorefs = [
{file = "mkdocs-autorefs-0.3.1.tar.gz", hash = "sha256:12baad29359f468b44d980ed35b713715409097a1d8e3d0ef90962db95205eda"},
{file = "mkdocs_autorefs-0.3.1-py3-none-any.whl", hash = "sha256:f0fd7c115eaafda7fb16bf5ff5d70eda55d7c0599eac64f8b25eacf864312a85"},
{file = "mkdocs-autorefs-0.3.0.tar.gz", hash = "sha256:2f89556eb2107d72e3aff41b04dcaaf1125d407a33b8027fbc982137d248d37d"},
{file = "mkdocs_autorefs-0.3.0-py3-none-any.whl", hash = "sha256:261875003e49b5d708993fd2792a69d624cbc8cf7de49e96c81d3d9825977ca4"},
]
mkdocs-click = [
{file = "mkdocs_click-0.4.0-py3-none-any.whl", hash = "sha256:3b54c65bd1e6e2b600da71d77705e911d15d86bc2c2b341ff5d7f76b9fe1505b"},
@@ -1468,8 +1454,8 @@ packaging = [
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
]
panaetius = [
{file = "panaetius-2.3.4-py3-none-any.whl", hash = "sha256:26b3f5bc213ea6e2076eecd46ff3adb8dba08a287756c948cc09a2bf504bc4d8"},
{file = "panaetius-2.3.4.tar.gz", hash = "sha256:da6884c12b1b79be4b338946cb4552cfcabf96e631f28068f95f1cf0842262f2"},
{file = "panaetius-2.3.3-py3-none-any.whl", hash = "sha256:44d8554dbeea25f16c7c36bc97e35369eb87c09b339a6347c6053ded00890569"},
{file = "panaetius-2.3.3.tar.gz", hash = "sha256:d984596a54f74763bc76664dcf04e41d080d20d8e458ccf42a9e7da1846cfcf2"},
]
pbr = [
{file = "pbr-5.8.0-py2.py3-none-any.whl", hash = "sha256:176e8560eaf61e127817ef93d8a844803abb27a4d4637f0ff3bb783129be2e0a"},
@@ -1542,8 +1528,8 @@ pyflakes = [
{file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"},
]
pygments = [
{file = "Pygments-2.11.2-py3-none-any.whl", hash = "sha256:44238f1b60a76d78fc8ca0528ee429702aae011c265fe6a8dd8b63049ae41c65"},
{file = "Pygments-2.11.2.tar.gz", hash = "sha256:4e426f72023d88d03b2fa258de560726ce890ff3b630f88c21cbb8b2503b8c6a"},
{file = "Pygments-2.10.0-py3-none-any.whl", hash = "sha256:b8e67fe6af78f492b3c4b3e2970c0624cbf08beb1e493b2c99b9fa1b67a20380"},
{file = "Pygments-2.10.0.tar.gz", hash = "sha256:f398865f7eb6874156579fdf36bc840a03cab64d1cde9e93d68f46a425ec52c6"},
]
pyinstaller = [
{file = "pyinstaller-4.5.1-py3-none-macosx_10_13_universal2.whl", hash = "sha256:ecc2baadeeefd2b6fbf39d13c65d4aa603afdda1c6aaaebc4577ba72893fee9e"},
@@ -1555,8 +1541,8 @@ pyinstaller = [
{file = "pyinstaller-4.5.1.tar.gz", hash = "sha256:30733baaf8971902286a0ddf77e5499ac5f7bf8e7c39163e83d4f8c696ef265e"},
]
pyinstaller-hooks-contrib = [
{file = "pyinstaller-hooks-contrib-2021.5.tar.gz", hash = "sha256:e47b382c209dd2f62ac2ef26cade49148e9a4702ec91958772b0270599f8c2a9"},
{file = "pyinstaller_hooks_contrib-2021.5-py2.py3-none-any.whl", hash = "sha256:e658281cbf90570d9bc6a06f4b8f64c28d1076c722f6fb80c02a863bcbb8e7cd"},
{file = "pyinstaller-hooks-contrib-2021.4.tar.gz", hash = "sha256:775b52200b39e12c95cc24f809eb050a97110fee819d178ebfde214f0f51e5f4"},
{file = "pyinstaller_hooks_contrib-2021.4-py2.py3-none-any.whl", hash = "sha256:60a57e4057fa2183bbaa81f10401a27eb7dd701ef8a11b287bb6345b571f94e7"},
]
pylint = [
{file = "pylint-2.12.2-py3-none-any.whl", hash = "sha256:daabda3f7ed9d1c60f52d563b1b854632fd90035bcf01443e234d3dc794e3b74"},
@@ -1656,8 +1642,8 @@ pyyaml-env-tag = [
{file = "pyyaml_env_tag-0.1.tar.gz", hash = "sha256:70092675bda14fdec33b31ba77e7543de9ddc88f2e5b99160396572d11525bdb"},
]
requests = [
{file = "requests-2.27.1-py2.py3-none-any.whl", hash = "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"},
{file = "requests-2.27.1.tar.gz", hash = "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61"},
{file = "requests-2.26.0-py2.py3-none-any.whl", hash = "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24"},
{file = "requests-2.26.0.tar.gz", hash = "sha256:b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7"},
]
requirements-detector = [
{file = "requirements-detector-0.7.tar.gz", hash = "sha256:0d1e13e61ed243f9c3c86e6cbb19980bcb3a0e0619cde2ec1f3af70fdbee6f7b"},
@@ -1703,8 +1689,8 @@ typing-extensions = [
{file = "typing_extensions-4.0.1.tar.gz", hash = "sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e"},
]
urllib3 = [
{file = "urllib3-1.26.8-py2.py3-none-any.whl", hash = "sha256:000ca7f471a233c2251c6c7023ee85305721bfdf18621ebff4fd17a8653427ed"},
{file = "urllib3-1.26.8.tar.gz", hash = "sha256:0e7c33d9a63e7ddfcb86780aac87befc2fbddf46c58dbb487e0855f7ceec283c"},
{file = "urllib3-1.26.7-py2.py3-none-any.whl", hash = "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"},
{file = "urllib3-1.26.7.tar.gz", hash = "sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece"},
]
watchdog = [
{file = "watchdog-2.1.6-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:9693f35162dc6208d10b10ddf0458cc09ad70c30ba689d9206e02cd836ce28a3"},
@@ -1785,6 +1771,6 @@ wrapt = [
{file = "wrapt-1.13.3.tar.gz", hash = "sha256:1fea9cd438686e6682271d36f3481a9f3636195578bab9ca3382e2f5f01fc185"},
]
zipp = [
{file = "zipp-3.7.0-py3-none-any.whl", hash = "sha256:b47250dd24f92b7dd6a0a8fc5244da14608f3ca90a5efcd37a3b1642fac9a375"},
{file = "zipp-3.7.0.tar.gz", hash = "sha256:9f50f446828eb9d45b267433fd3e9da8d801f614129124863f9c51ebceafb87d"},
{file = "zipp-3.6.0-py3-none-any.whl", hash = "sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc"},
{file = "zipp-3.6.0.tar.gz", hash = "sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832"},
]

View File

@@ -37,7 +37,7 @@ pylint:
min-public-methods: 0
max-public-methods: 25
max-module-lines: 1000
max-line-length: 120
max-line-length: 99
max-args: 8
mccabe:

View File

@@ -2,7 +2,7 @@ click==8.0.3; python_version >= "3.6"
colorama==0.4.4; python_version >= "3.6" and python_full_version < "3.0.0" and platform_system == "Windows" or platform_system == "Windows" and python_version >= "3.6" and python_full_version >= "3.5.0"
jinja2==3.0.3; python_version >= "3.6"
markupsafe==2.0.1; python_version >= "3.6"
panaetius==2.3.4; python_version >= "3.7" and python_version < "4.0"
panaetius==2.3.3; python_version >= "3.7" and python_version < "4.0"
pendulum==2.1.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
python-dateutil==2.8.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
pytzdata==2020.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"

View File

@@ -1,12 +1,12 @@
altgraph==0.17.2; sys_platform == "darwin" and python_version >= "3.6"
ansimarkup==1.5.0; python_version >= "3.6"
astroid==2.9.2; python_full_version >= "3.6.2" and python_version < "4.0"
astroid==2.9.0; python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.2"
astunparse==1.6.3; python_full_version >= "3.6.1" and python_version >= "3.6" and python_version < "3.9"
atomicwrites==1.4.0; python_version >= "3.6" and python_full_version < "3.0.0" and sys_platform == "win32" or sys_platform == "win32" and python_version >= "3.6" and python_full_version >= "3.4.0"
attrs==21.4.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
attrs==21.2.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
bandit==1.7.1; python_full_version >= "3.6.1" and python_version < "4.0" and python_version >= "3.5"
certifi==2021.10.8; python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.5"
charset-normalizer==2.0.10; python_full_version >= "3.6.0" and python_version >= "3.5"
charset-normalizer==2.0.9; python_full_version >= "3.6.0" and python_version >= "3.5"
click==8.0.3; python_version >= "3.6"
colorama==0.4.4; platform_system == "Windows" and python_version >= "3.6" and python_full_version >= "3.6.2" and sys_platform == "win32" and python_version < "4.0"
coverage==6.2; python_version >= "3.6"
@@ -26,13 +26,13 @@ importlib-metadata==4.10.0; python_version < "3.10" and python_version >= "3.7"
iniconfig==1.1.1; python_version >= "3.6"
isort==5.10.1; python_full_version >= "3.6.1" and python_version < "4.0"
jinja2==3.0.3; python_version >= "3.6"
lazy-object-proxy==1.7.1; python_full_version >= "3.6.2" and python_version < "4.0" and python_version >= "3.6"
lazy-object-proxy==1.7.1; python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.2"
macholib==1.15.2; sys_platform == "darwin" and python_version >= "3.6"
markdown==3.3.6; python_full_version >= "3.6.2" and python_full_version < "4.0.0" and python_version >= "3.7"
markdown==3.3.6; python_version >= "3.7" and python_version < "4.0"
markupsafe==2.0.1; python_version >= "3.6"
mccabe==0.6.1; python_full_version >= "3.6.2" and python_version < "4.0"
mergedeep==1.3.4; python_version >= "3.6"
mkdocs-autorefs==0.3.1; python_full_version >= "3.6.2" and python_full_version < "4.0.0" and python_version >= "3.6"
mkdocs-autorefs==0.3.0; python_version >= "3.6" and python_version < "4.0"
mkdocs-click==0.4.0; python_version >= "3.7"
mkdocs-coverage==0.2.5; python_full_version >= "3.6.2"
mkdocs-gen-files==0.3.3; python_version >= "3.7" and python_version < "4.0"
@@ -44,7 +44,7 @@ mkdocstrings==0.16.2; python_version >= "3.6"
mypy-extensions==0.4.3; python_full_version >= "3.6.1" and python_version < "4.0" and python_version >= "3.5"
mypy==0.910; python_version >= "3.5"
packaging==21.3; python_version >= "3.6"
panaetius==2.3.4; python_version >= "3.7" and python_version < "4.0"
panaetius==2.3.3; python_version >= "3.7" and python_version < "4.0"
pbr==5.8.0; python_full_version >= "3.6.1" and python_version < "4.0" and python_version >= "3.6"
pefile==2021.9.3; sys_platform == "win32" and python_version >= "3.6" and python_full_version >= "3.6.0"
pendulum==2.1.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
@@ -58,7 +58,7 @@ py==1.11.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_
pycodestyle==2.8.0; python_full_version >= "3.6.1" and python_version < "4.0"
pydocstyle==6.1.1; python_full_version >= "3.6.1" and python_version < "4.0" and python_version >= "3.6"
pyflakes==2.3.1; python_full_version >= "3.6.1" and python_version < "4.0"
pygments==2.11.1; python_version >= "3.5"
pygments==2.10.0; python_version >= "3.5"
pyinstaller-hooks-contrib==2021.4; python_version >= "3.6"
pyinstaller==4.5.1; python_version >= "3.6"
pylint-celery==0.3; python_full_version >= "3.6.1" and python_version < "4.0"
@@ -78,7 +78,7 @@ pytzdata==2020.1; python_version >= "2.7" and python_full_version < "3.0.0" or p
pywin32-ctypes==0.2.0; sys_platform == "win32" and python_version >= "3.6"
pyyaml-env-tag==0.1; python_version >= "3.6"
pyyaml==6.0; python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.6.1"
requests==2.27.0; python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.5"
requests==2.26.0; python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.5"
requirements-detector==0.7; python_full_version >= "3.6.1" and python_version < "4.0"
safety==1.10.3; python_version >= "3.5"
semver==2.13.0; python_full_version >= "3.6.2"
@@ -92,5 +92,5 @@ tomli==2.0.0; python_version >= "3.7"
typing-extensions==4.0.1; python_full_version >= "3.6.2" and python_version < "3.10" and python_version >= "3.7"
urllib3==1.26.7; python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.5"
watchdog==2.1.6; python_version >= "3.6"
wrapt==1.13.3; python_full_version >= "3.6.2" and python_version < "4.0"
zipp==3.7.0; python_version >= "3.7"
wrapt==1.13.3; python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.2"
zipp==3.6.0; python_version >= "3.7"

View File

@@ -201,7 +201,7 @@ def cli_message(message: str) -> None:
Relay a message to the user using the CLI.
Args:
message (str): The message to be displayed.
message (str): THe message to be displayed.
"""
click.echo(f"[TEMBO] {message} 🐘")

View File

@@ -1,202 +0,0 @@
"""Submodule containing the abstract factories to create Tembo pages."""
from __future__ import annotations
import pathlib
from abc import ABCMeta, abstractmethod
from typing import TYPE_CHECKING
import jinja2
from jinja2.exceptions import TemplateNotFound
import tembo.utils
from tembo import exceptions
if TYPE_CHECKING:
from tembo.journal.pages import PageCreatorOptions
class PageCreator:
"""
A PageCreator factory base class.
This factory should implement methods to create [Page][tembo.journal.pages.Page] objects.
!!! abstract
This factory is an abstract base class and should be implemented for each
[Page][tembo.journal.pages.Page] type.
The methods
- `_check_base_path_exists()`
- `_convert_base_path_to_path()`
- `_load_template()`
are not abstract and are shared between all [Page][tembo.journal.pages.Page] types.
"""
@abstractmethod
def __init__(self, options: PageCreatorOptions) -> None:
"""
When implemented this should initialise the `PageCreator` factory.
Args:
options (PageCreatorOptions): An instance of
[PageCreatorOptions][tembo.journal.pages.PageCreatorOptions]
!!! abstract
This method is abstract and should be implemented for each
[Page][tembo.journal.pages.Page] type.
"""
raise NotImplementedError
@property
@abstractmethod
def options(self) -> PageCreatorOptions:
"""
When implemented this should return the `PageCreatorOptions` on the class.
Returns:
PageCreatorOptions: the instance of
[PageCreatorOptions][tembo.journal.pages.PageCreatorOptions] set on the class.
!!! abstract
This method is abstract and should be implemented for each
[Page][tembo.journal.pages.Page] type.
"""
raise NotImplementedError
@abstractmethod
def create_page(self) -> Page:
"""
When implemented this should create a `Page` object.
Returns:
Page: an implemented instance of [Page][tembo.journal.pages.Page] such as
[ScopedPage][tembo.journal.pages.ScopedPage].
!!! abstract
This method is abstract and should be implemented for each
[Page][tembo.journal.pages.Page] type.
"""
raise NotImplementedError
def _check_base_path_exists(self) -> None:
"""
Check that the base path exists.
Raises:
exceptions.BasePathDoesNotExistError: raised if the base path does not exist.
"""
if not pathlib.Path(self.options.base_path).expanduser().exists():
raise exceptions.BasePathDoesNotExistError(
f"Tembo base path of {self.options.base_path} does not exist."
)
def _convert_base_path_to_path(self) -> pathlib.Path:
"""
Convert the `base_path` from a `str` to a `pathlib.Path` object.
Returns:
pathlib.Path: the `base_path` as a `pathlib.Path` object.
"""
path_to_file = (
pathlib.Path(self.options.base_path).expanduser()
/ pathlib.Path(self.options.page_path.replace(" ", "_")).expanduser()
/ self.options.filename.replace(" ", "_")
)
# check for existing `.` in the extension
extension = (
self.options.extension[1:]
if self.options.extension[0] == "."
else self.options.extension
)
# return path with a file
return path_to_file.with_suffix(f".{extension}")
def _load_template(self) -> str:
"""
Load the template file.
Raises:
exceptions.TemplateFileNotFoundError: raised if the template file is specified but
not found.
Returns:
str: the contents of the template file.
"""
if self.options.template_filename is None:
return ""
if self.options.template_path is not None:
converted_template_path = pathlib.Path(self.options.template_path).expanduser()
else:
converted_template_path = (
pathlib.Path(self.options.base_path).expanduser() / ".templates"
)
file_loader = jinja2.FileSystemLoader(converted_template_path)
env = jinja2.Environment(loader=file_loader, autoescape=True)
try:
loaded_template = env.get_template(self.options.template_filename)
except TemplateNotFound as template_not_found:
_template_file = f"{converted_template_path}/{template_not_found.args[0]}"
raise exceptions.TemplateFileNotFoundError(
f"Template file {_template_file} does not exist."
) from template_not_found
return loaded_template.render()
class Page(metaclass=ABCMeta):
"""
Abstract Page class.
This interface is used to define a `Page` object.
A `Page` represents a note/page that will be saved to disk.
!!! abstract
This object is an abstract base class and should be implemented for each `Page` type.
"""
@abstractmethod
def __init__(self, path: pathlib.Path, page_content: str) -> None:
"""
When implemented this should initalise a Page object.
Args:
path (pathlib.Path): the full path of the page including the filename as a
[Path][pathlib.Path].
page_content (str): the contents of the page.
!!! abstract
This method is abstract and should be implemented for each `Page` type.
"""
raise NotImplementedError
@property
@abstractmethod
def path(self) -> pathlib.Path:
"""
When implemented this should return the full path of the page including the filename.
Returns:
pathlib.Path: the path as a [Path][pathlib.Path] object.
!!! abstract
This property is abstract and should be implemented for each `Page` type.
"""
raise NotImplementedError
@abstractmethod
def save_to_disk(self) -> tembo.utils.Success:
"""
When implemented this should save the page to disk.
Returns:
tembo.utils.Success: A Tembo [Success][tembo.utils.__init__.Success] object.
!!! abstract
This method is abstract and should be implemented for each `Page` type.
"""
raise NotImplementedError

View File

@@ -4,14 +4,16 @@ from __future__ import annotations
import pathlib
import re
from abc import ABCMeta, abstractmethod
from dataclasses import dataclass
from typing import Collection, Optional
import jinja2
import pendulum
from jinja2.exceptions import TemplateNotFound
import tembo.utils
from tembo import exceptions
from tembo.journal.abstract import Page, PageCreator
@dataclass
@@ -46,6 +48,137 @@ class PageCreatorOptions:
template_filename: Optional[str] = None
class PageCreator:
"""
A PageCreator factory base class.
This factory should implement methods to create [Page][tembo.journal.pages.Page] objects.
!!! abstract
This factory is an abstract base class and should be implemented for each
[Page][tembo.journal.pages.Page] type.
The private methods
- `_check_base_path_exists()`
- `_convert_base_path_to_path()`
- `_load_template()`
are not abstract and are shared between all [Page][tembo.journal.pages.Page] types.
"""
@abstractmethod
def __init__(self, options: PageCreatorOptions) -> None:
"""
When implemented this should initialise the `PageCreator` factory.
Args:
options (PageCreatorOptions): An instance of
[PageCreatorOptions][tembo.journal.pages.PageCreatorOptions]
!!! abstract
This method is abstract and should be implemented for each
[Page][tembo.journal.pages.Page] type.
"""
raise NotImplementedError
@property
@abstractmethod
def options(self) -> PageCreatorOptions:
"""
When implemented this should return the `PageCreatorOptions` on the class.
Returns:
PageCreatorOptions: the instance of
[PageCreatorOptions][tembo.journal.pages.PageCreatorOptions] set on the class.
!!! abstract
This method is abstract and should be implemented for each
[Page][tembo.journal.pages.Page] type.
"""
raise NotImplementedError
@abstractmethod
def create_page(self) -> Page:
"""
When implemented this should create a `Page` object.
Returns:
Page: an implemented instance of [Page][tembo.journal.pages.Page] such as
[ScopedPage][tembo.journal.pages.ScopedPage].
!!! abstract
This method is abstract and should be implemented for each
[Page][tembo.journal.pages.Page] type.
"""
raise NotImplementedError
def _check_base_path_exists(self) -> None:
"""
Check that the base path exists.
Raises:
exceptions.BasePathDoesNotExistError: raised if the base path does not exist.
"""
if not pathlib.Path(self.options.base_path).expanduser().exists():
raise exceptions.BasePathDoesNotExistError(
f"Tembo base path of {self.options.base_path} does not exist."
)
def _convert_base_path_to_path(self) -> pathlib.Path:
"""
Convert the `base_path` from a `str` to a `pathlib.Path` object.
Returns:
pathlib.Path: the `base_path` as a `pathlib.Path` object.
"""
path_to_file = (
pathlib.Path(self.options.base_path).expanduser()
/ pathlib.Path(self.options.page_path.replace(" ", "_")).expanduser()
/ self.options.filename.replace(" ", "_")
)
# check for existing `.` in the extension
extension = (
self.options.extension[1:]
if self.options.extension[0] == "."
else self.options.extension
)
# return path with a file
return path_to_file.with_suffix(f".{extension}")
def _load_template(self) -> str:
"""
Load the template file.
Raises:
exceptions.TemplateFileNotFoundError: raised if the template file is specified but
not found.
Returns:
str: the contents of the template file.
"""
if self.options.template_filename is None:
return ""
if self.options.template_path is not None:
converted_template_path = pathlib.Path(self.options.template_path).expanduser()
else:
converted_template_path = (
pathlib.Path(self.options.base_path).expanduser() / ".templates"
)
file_loader = jinja2.FileSystemLoader(converted_template_path)
env = jinja2.Environment(loader=file_loader, autoescape=True)
try:
loaded_template = env.get_template(self.options.template_filename)
except TemplateNotFound as template_not_found:
_template_file = f"{converted_template_path}/{template_not_found.args[0]}"
raise exceptions.TemplateFileNotFoundError(
f"Template file {_template_file} does not exist."
) from template_not_found
return loaded_template.render()
class ScopedPageCreator(PageCreator):
"""
Factory to create a scoped page.
@@ -222,11 +355,68 @@ class ScopedPageCreator(PageCreator):
return tokenified_string
class Page(metaclass=ABCMeta):
"""
Abstract Page class.
This interface is used to define a `Page` object.
A `Page` represents a note/page that will be saved to disk.
!!! abstract
This object is an abstract base class and should be implemented for each `Page` type.
"""
@abstractmethod
def __init__(self, path: pathlib.Path, page_content: str) -> None:
"""
When implemented this should initalise a Page object.
Args:
path (pathlib.Path): the full path of the page including the filename as a
[Path][pathlib.Path].
page_content (str): the contents of the page.
!!! abstract
This method is abstract and should be implemented for each `Page` type.
"""
raise NotImplementedError
@property
@abstractmethod
def path(self) -> pathlib.Path:
"""
When implemented this should return the full path of the page including the filename.
Returns:
pathlib.Path: the path as a [Path][pathlib.Path] object.
!!! abstract
This property is abstract and should be implemented for each `Page` type.
"""
raise NotImplementedError
@abstractmethod
def save_to_disk(self) -> tembo.utils.Success:
"""
When implemented this should save the page to disk.
Returns:
tembo.utils.Success: A Tembo [Success][tembo.utils.__init__.Success] object.
!!! abstract
This method is abstract and should be implemented for each `Page` type.
"""
raise NotImplementedError
class ScopedPage(Page):
"""
A page that uses substitute tokens.
Attributes:
path (pathlib.Path): a [Path][pathlib.Path] object of the page's filepath including the
filename.
page_content (str): the content of the page from the template.
"""
@@ -272,8 +462,9 @@ class ScopedPage(Page):
Save the scoped page to disk and write the `page_content`.
Raises:
exceptions.ScopedPageAlreadyExists: Raises
[ScopedPageAlreadyExists][tembo.exceptions.ScopedPageAlreadyExists] if the page already exists.
exceptions.ScopedPageAlreadyExists: If the page already exists a
[ScopedPageAlreadyExists][tembo.exceptions.ScopedPageAlreadyExists] exception
is raised.
Returns:
tembo.utils.Success: A [Success][tembo.utils.__init__.Success] with the path of the

View File

@@ -5,7 +5,7 @@ import pathlib
import pytest
import tembo.cli
from tembo.cli.cli import list_all, new
from tembo.cli.cli import new, list_all
def test_new_dry_run(shared_datadir, tmpdir, capsys):

View File

@@ -1,11 +1,13 @@
import pathlib
from datetime import date
import pathlib
import pytest
from tembo import PageCreatorOptions, ScopedPageCreator, exceptions
from tembo import PageCreatorOptions, ScopedPageCreator
from tembo import exceptions
from tembo.utils import Success
DATE_TODAY = date.today().strftime("%d-%m-%Y")