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
This commit is contained in:
Adam Goldsmith 2015-08-08 19:24:14 -04:00
parent 1a085b68c5
commit 2228672a16
1 changed files with 8 additions and 3 deletions

11
test.py
View File

@ -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)