1 # -*- coding: utf-8 -*-
 
   3 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
 
   4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 
   7 from urllib2 import urlopen, URLError
 
   9 from librarian import DCNS, BuildError
 
  13 class EvensCover(Cover):
 
  14     format_name = u"Evens cover image"
 
  21     def set_images(self, ctx):
 
  22         cover_url = self.doc.meta.get(DCNS('relation.coverimage.url'))[0]
 
  24             raise BuildError('No cover specified')
 
  25         if cover_url.startswith('file://'):
 
  26             cover_url = ctx.files_path + urllib.quote(cover_url[7:])
 
  28             self.background_img = urlopen(cover_url)
 
  30             raise BuildError('Cannot open the cover image: %s' % cover_url)
 
  32         if getattr(ctx, 'cover_logo', None):
 
  34             self.logo_file = urlopen(ctx.cover_logo)