aboutsummaryrefslogtreecommitdiff
path: root/model.py
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2024-03-23 19:21:30 +0000
committerJuan J. Martinez <jjm@usebox.net>2024-03-23 19:21:30 +0000
commit894babd9250c02adb5e713d2f54c8ea6af02f3ca (patch)
tree565f82e239492fad41e3c5cb6f88c7afdeb8aec0 /model.py
parent5e1bcdca7c5a79119adec162ffa367741b23596c (diff)
downloadpersonal-wiki-pybottle-894babd9250c02adb5e713d2f54c8ea6af02f3ca.tar.gz
personal-wiki-pybottle-894babd9250c02adb5e713d2f54c8ea6af02f3ca.zip
Use inflection
Diffstat (limited to 'model.py')
-rw-r--r--model.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/model.py b/model.py
index 3f52115..a69ed99 100644
--- a/model.py
+++ b/model.py
@@ -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