[library-web] [mallard] do not fail on invalid file



commit c75ea1c20dcf59126b15205f85a84ef44dd5dde9
Author: Frédéric Péters <fpeters 0d be>
Date:   Thu Jan 28 10:09:42 2010 +0100

    [mallard] do not fail on invalid file

 src/modtypes/mallard.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/modtypes/mallard.py b/src/modtypes/mallard.py
index 38b542a..98f7e58 100644
--- a/src/modtypes/mallard.py
+++ b/src/modtypes/mallard.py
@@ -47,6 +47,7 @@ MAL_NS = 'http://projectmallard.org/1.0/'
 
 
 class MallardPage:
+    id = None
     link_title = None
     sort_title = None
     info_nodes = None
@@ -55,7 +56,10 @@ class MallardPage:
         self.info_nodes = []
 
         tree = ET.parse(filename)
-        self.id = tree.getroot().attrib['id']
+        try:
+            self.id = tree.getroot().attrib['id']
+        except KeyError:
+            pass
         if self.id is None:
             return
         self.page_info(tree.find('{%s}info' % MAL_NS))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]