X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/87ff0a2df51103379aee4fe2724e90f3e690ef03..2976553c3f33b52495ea4ba4335e22f7c068fdf4:/lib/librarian/dcparser.py 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)