From 97397144f7ea06f15d3e6e3e3bdb5ddf59f5f1ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20St=C4=99pniowski?= Date: Thu, 9 Oct 2008 15:52:22 +0200 Subject: [PATCH] Add to_dict method to BookInfo class in dcparser. --- lib/librarian/dcparser.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/librarian/dcparser.py b/lib/librarian/dcparser.py index 871ff3a92..8542553cf 100644 --- a/lib/librarian/dcparser.py +++ b/lib/librarian/dcparser.py @@ -165,6 +165,17 @@ class BookInfo(object): return unicode(etree.tostring(root, 'utf-8'), 'utf-8') + def to_dict(self): + etree._namespace_map[str(self.RDF)] = 'rdf' + etree._namespace_map[str(self.DC)] = 'dc' + + result = {} + for tag, (attribute, converter) in self.mapping.iteritems(): + if hasattr(self, attribute): + result[attribute] = unicode(getattr(self, attribute)) + + return result + def parse(file_name): return BookInfo.from_file(file_name) -- 2.20.1