diff options
author | Juan J. Martinez <jjm@usebox.net> | 2024-03-23 19:21:30 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2024-03-23 19:21:30 +0000 |
commit | 894babd9250c02adb5e713d2f54c8ea6af02f3ca (patch) | |
tree | 565f82e239492fad41e3c5cb6f88c7afdeb8aec0 /model.py | |
parent | 5e1bcdca7c5a79119adec162ffa367741b23596c (diff) | |
download | personal-wiki-pybottle-894babd9250c02adb5e713d2f54c8ea6af02f3ca.tar.gz personal-wiki-pybottle-894babd9250c02adb5e713d2f54c8ea6af02f3ca.zip |
Use inflection
Diffstat (limited to 'model.py')
-rw-r--r-- | model.py | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -2,6 +2,7 @@ import sqlite3 from datetime import datetime import re +import inflection import markdown @@ -40,9 +41,13 @@ class Page(object): def render(self): return markdown.markdown(self.content) + def validate(self): + if self.name != inflection.camelize(self.name): + raise ValueError("Invalid page name, must be CamelCase") + @property def title(self): - pretty = " ".join(re.findall(r"[A-Z](?:[a-z]+|[A-Z]*(?=[A-Z]|$))", self.name)) + pretty = inflection.titleize(self.name) if self.history: pretty = f"{pretty} (history)" return pretty |