X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/97397144f7ea06f15d3e6e3e3bdb5ddf59f5f1ed..40b0da924b62ba147588a945718b71dc36ed3702:/lib/librarian/dcparser.py?ds=sidebyside diff --git a/lib/librarian/dcparser.py b/lib/librarian/dcparser.py index 8542553cf..557509c95 100644 --- a/lib/librarian/dcparser.py +++ b/lib/librarian/dcparser.py @@ -117,6 +117,8 @@ class BookInfo(object): DC('source.URL') : ('source_url', str_to_unicode), DC('identifier.url') : ('url', str_to_unicode), DC('relation.hasPart') : ('parts', str_to_unicode_list), + DC('rights.license') : ('license', str_to_unicode), + DC('rights') : ('license_description', str_to_unicode), } @classmethod @@ -134,6 +136,8 @@ class BookInfo(object): raise ParseError(e) description = tree.find('//' + book_info.RDF('Description')) + book_info.wiki_url = description.get(cls.RDF('about'), None) + if description is None: raise ParseError('no Description tag found in document') @@ -157,6 +161,9 @@ class BookInfo(object): root = etree.Element(self.RDF('RDF')) description = etree.SubElement(root, self.RDF('Description')) + if self.wiki_url: + description.set(self.RDF('about'), self.wiki_url) + for tag, (attribute, converter) in self.mapping.iteritems(): if hasattr(self, attribute): e = etree.Element(tag) @@ -169,7 +176,7 @@ class BookInfo(object): etree._namespace_map[str(self.RDF)] = 'rdf' etree._namespace_map[str(self.DC)] = 'dc' - result = {} + result = {'about': self.wiki_url} for tag, (attribute, converter) in self.mapping.iteritems(): if hasattr(self, attribute): result[attribute] = unicode(getattr(self, attribute))