Add support for predesigned covers to Marquise. Remove support for changing cover...
[librarian.git] / src / librarian / cover.py
index b60ec34..9cd813a 100644 (file)
@@ -72,7 +72,7 @@ class TextBox(object):
                     break
                 line = parts[0]
 
-                if line[-2] == ' ':
+                if len(line) > 2 and line[-2] == ' ':
                     line = line[:-2]
 
                 line_width = self.draw.textsize(line, font=font)[0]
@@ -153,6 +153,15 @@ class Cover(object):
 
     def __init__(self, book_info, format=None, width=None, height=None, cover_logo=None):
         self.book_info = book_info
+
+        self.predesigned = False
+        if book_info.cover_class == 'image':
+            self.predesigned = True
+
+        # TODO: deprecated
+        if book_info.cover_box_position == 'none':
+            self.predesigned = True
+
         self.authors = [auth.readable() for auth in book_info.authors]
         self.title = book_info.title
         if format is not None:
@@ -989,7 +998,7 @@ class FactoryCover(LogoWLCover):
 from librarian.covers.marquise import MarquiseCover, LabelMarquiseCover
 
 COVER_CLASSES = {
-    'default': LogoWLCover,
+    'legacy': LogoWLCover,
     'kmlu': KMLUCover,
     'mpw': MPWCover,
     'atrium': AtriumCover,
@@ -1000,13 +1009,15 @@ COVER_CLASSES = {
     'factory': FactoryCover,
     'm': MarquiseCover,
     'm-label': LabelMarquiseCover,
+    'default': MarquiseCover,
 }
 
 
 def make_cover(book_info, *args, **kwargs):
+    cover_class_name = None
     if 'cover_class' in kwargs:
         cover_class_name = kwargs.pop('cover_class')
-    else:
-        cover_class_name = book_info.cover_class
+    if not cover_class_name:
+        cover_class_name = 'default'
     cover_class = COVER_CLASSES[cover_class_name]
     return cover_class(book_info, *args, **kwargs)