--- a/lib/page_tree.py Sat Feb 07 02:46:58 2009 +0200
+++ b/lib/page_tree.py Sat Feb 07 02:51:36 2009 +0200
@@ -7,6 +7,12 @@
# path to file containing the page metadata tree
PAGE_TREE_FILE = "pages/list"
+class PageTreeError (Exception) :
+ """
+ Error parsing/loading the page tree
+ """
+
+ pass
class PageInfo (object) :
"""
@@ -118,6 +124,9 @@
# parse tree
tree = tree_parse.parse(path, ':')
+ if not tree :
+ raise PageTreeError("No root node found")
+
def _create_node (parent, item) :
"""
Creates and returns a PageInfo from the given parent node and (line_number, line, children) tuple item
@@ -125,9 +134,15 @@
# unpack
line_number, line, children = item
+
+ # parse line
+ url = title = None
+
+ try :
+ url, title = line.split(':')
- # parse line
- url, title = line.split(':')
+ except :
+ raise PageTreeError("Invalid line: %s:%d: %r" % (path, line_number, line))
# remove whitespace
url = url.strip()