From: Jan Szejko Date: Tue, 25 Apr 2017 16:02:28 +0000 (+0200) Subject: multiple audience in pdf/epub X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/4b958ca8fc156576373e1d805fff96fb34a35804?ds=inline multiple audience in pdf/epub --- diff --git a/librarian/formats/epub/__init__.py b/librarian/formats/epub/__init__.py index 4b6cf13..36891be 100644 --- a/librarian/formats/epub/__init__.py +++ b/librarian/formats/epub/__init__.py @@ -35,8 +35,11 @@ class EpubFormat(Format): if cover is not None: self.cover = cover - def dc(self, tag): - return self.doc.meta.get_one(DCNS(tag)) + def dc(self, tag, multiple=False): + if multiple: + return ', '.join(self.doc.meta.get(DCNS(tag))) + else: + return self.doc.meta.get_one(DCNS(tag)) def build(self, ctx=None): @@ -158,7 +161,7 @@ class EpubFormat(Format): 'Information about the resource', 'Publisher: %s' % self.dc('publisher'), 'Rights: %s' % self.dc('rights'), - 'Intended audience: %s' % self.dc('audience'), + 'Intended audience: %s' % self.dc('audience', multiple=True), self.dc('description'), 'Resource prepared using MIL/PEER editing platform.', 'Source available at %s' % ctx.source_url, diff --git a/librarian/formats/pdf/__init__.py b/librarian/formats/pdf/__init__.py index a994008..a8fe38f 100644 --- a/librarian/formats/pdf/__init__.py +++ b/librarian/formats/pdf/__init__.py @@ -185,12 +185,15 @@ class PdfFormat(Format): doc.append(texml_cmd("section*", "Information about the resource")) doc.append(texml_cmd("vspace", "1em")) - for m, f in ( - ('Publisher: ', DCNS('publisher')), - ('Rights: ', DCNS('rights')), - ('Intended audience: ', DCNS('audience')), - ('', DCNS('description'))): - v = self.doc.meta.get_one(f) + for m, f, multiple in ( + ('Publisher: ', DCNS('publisher'), False), + ('Rights: ', DCNS('rights'), False), + ('Intended audience: ', DCNS('audience'), True), + ('', DCNS('description'), False)): + if multiple: + v = ', '.join(self.doc.meta.get(f)) + else: + v = self.doc.meta.get_one(f) if v: e = texml_cmd("par", "") e[0].append(texml_cmd("noindent"))