fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2ef63bb
)
Add to_dict method to BookInfo class in dcparser.
author
Marek Stępniowski
<marek@stepniowski.com>
Thu, 9 Oct 2008 13:52:22 +0000
(15:52 +0200)
committer
Marek Stępniowski
<marek@stepniowski.com>
Thu, 9 Oct 2008 13:52:22 +0000
(15:52 +0200)
lib/librarian/dcparser.py
patch
|
blob
|
history
diff --git
a/lib/librarian/dcparser.py
b/lib/librarian/dcparser.py
index
871ff3a
..
8542553
100644
(file)
--- 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)