X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/8495b2ce8e9aebe778db74217b60fb68c0b5f9f2..cef5307b16e8df550c9ecf9704449e55b9137be2:/src/librarian/cover.py?ds=sidebyside diff --git a/src/librarian/cover.py b/src/librarian/cover.py index b60ec34..9cd813a 100644 --- a/src/librarian/cover.py +++ b/src/librarian/cover.py @@ -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)