From: Radek Czajka Date: Thu, 22 Jun 2023 07:24:44 +0000 (+0200) Subject: Change default cover. X-Git-Tag: 2.6~1 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/af72c4ed58e541d491dafbfe4ecb163662f402b5?ds=sidebyside Change default cover. --- diff --git a/setup.py b/setup.py index 267195f..c300f27 100755 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def whole_tree(prefix, path): setup( name='librarian', - version='2.5.1', + version='2.6', description='Converter from WolneLektury.pl XML-based language to XHTML, TXT and other formats', author="Marek Stępniowski", author_email='marek@stepniowski.com', diff --git a/src/librarian/cover.py b/src/librarian/cover.py index 4fd3d45..0e9b079 100644 --- a/src/librarian/cover.py +++ b/src/librarian/cover.py @@ -989,7 +989,7 @@ class FactoryCover(LogoWLCover): from librarian.covers.marquise import MarquiseCover, LabelMarquiseCover COVER_CLASSES = { - 'default': LogoWLCover, + 'legacy': LogoWLCover, 'kmlu': KMLUCover, 'mpw': MPWCover, 'atrium': AtriumCover, @@ -1000,6 +1000,7 @@ COVER_CLASSES = { 'factory': FactoryCover, 'm': MarquiseCover, 'm-label': LabelMarquiseCover, + 'default': MarquiseCover, } diff --git a/src/librarian/covers/utils/textbox.py b/src/librarian/covers/utils/textbox.py index a5097ed..cc9c501 100644 --- a/src/librarian/covers/utils/textbox.py +++ b/src/librarian/covers/utils/textbox.py @@ -80,6 +80,8 @@ class TextBox: def find_grouping(self, groups, ngroups, glue): best = None best_var = None + if not groups: + return [] mean = sum(g[0] for g in groups) + (len(groups) - ngroups) * glue if mean > self.width * ngroups: diff --git a/src/librarian/covers/widgets/author.py b/src/librarian/covers/widgets/author.py index 5fa3528..4060999 100644 --- a/src/librarian/covers/widgets/author.py +++ b/src/librarian/covers/widgets/author.py @@ -31,6 +31,7 @@ class AuthorBox(Widget): authors = [a.readable() for a in self.cover.book_info.authors] translators = [a.readable() for a in self.cover.book_info.translators] + self.textboxes = [] if authors and translators: # Try with two boxes. @@ -130,7 +131,8 @@ class AuthorBox(Widget): self.textboxes = [author_box] - self.margin_top = self.textboxes[0].margin_top + if self.textboxes: + self.margin_top = self.textboxes[0].margin_top def build(self, w, h): img = PIL.Image.new('RGBA', (self.width, self.m.leading * 2)) diff --git a/src/librarian/covers/widgets/background.py b/src/librarian/covers/widgets/background.py index 8c9e03b..7836b5c 100644 --- a/src/librarian/covers/widgets/background.py +++ b/src/librarian/covers/widgets/background.py @@ -9,6 +9,7 @@ class Background(Widget): transparency = False def setup(self): + self.img = None if self.cover.book_info.cover_url: while True: try: @@ -34,6 +35,8 @@ class Background(Widget): self.img = img def build(self, w, h): + if not self.img: + return kwadrat = round(max(w, h)) img = self.img img = self.img.resize((kwadrat, kwadrat)) diff --git a/src/librarian/covers/widgets/base.py b/src/librarian/covers/widgets/base.py index 15e4462..9c56693 100644 --- a/src/librarian/covers/widgets/base.py +++ b/src/librarian/covers/widgets/base.py @@ -14,8 +14,9 @@ class Widget: def apply(self, img, x, y, w=None, h=None): my_img = self.build(w, h) - img.paste( - my_img, - (round(x), round(y - self.margin_top)), - my_img if self.transparency else None - ) + if my_img is not None: + img.paste( + my_img, + (round(x), round(y - self.margin_top)), + my_img if self.transparency else None + )