From 2228672a16c62f111af4dbb994a85debb53789b9 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 8 Aug 2015 19:24:14 -0400 Subject: [PATCH] switch to individual parsing of data allows for exceptions like authors, date, etc. will hopefully switch back as soon as I figure out a generic way to do so --- test.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test.py b/test.py index 11c938d..3a4806d 100644 --- a/test.py +++ b/test.py @@ -19,9 +19,14 @@ def main(): for book in collection.iter(ns + "entry"): bookout = {} - for datum in data: - d = book.find(ns + datum) - bookout[datum] = d.text if (d != None) else "" + bookout["title"] = book.find(ns + "title").text if (book.find(ns + "title") != None) else "" + bookout["isbn"] = book.find(ns + "isbn").text if (book.find(ns + "isbn") != None) else "" + authors = [] + if book.find(ns + "authors") != None: + for a in book.find(ns + "authors"): + authors.append(a.text) + bookout["authors"] = "; ".join(authors) + out.append(bookout.copy()) return render_template("books.html", books = out, data = data)