diff --git a/bookwyrm/apps.py b/bookwyrm/apps.py index c30b7c8f7..c2dfd4b81 100644 --- a/bookwyrm/apps.py +++ b/bookwyrm/apps.py @@ -1,3 +1,4 @@ +"""Do further startup configuration and initialization""" import os import urllib import logging @@ -10,15 +11,18 @@ logger = logging.getLogger(__name__) def download_file(url, destination): + """Downloads a file to the given path""" try: - stream = urllib.request.urlopen(url) - with open(destination, "b+w") as f: - f.write(stream.read()) + with urllib.request.urlopen(url) as stream: + with open(destination, "b+w") as outfile: + outfile.write(stream.read()) except (urllib.error.HTTPError, urllib.error.URLError): logger.error("Failed to download file %s", url) class BookwyrmConfig(AppConfig): + """Handles additional configuration""" + name = "bookwyrm" verbose_name = "BookWyrm" diff --git a/bookwyrm/preview_images.py b/bookwyrm/preview_images.py index 325742d72..891c8b6da 100644 --- a/bookwyrm/preview_images.py +++ b/bookwyrm/preview_images.py @@ -4,7 +4,6 @@ import os import textwrap from io import BytesIO from uuid import uuid4 -import urllib import logging import colorsys @@ -36,6 +35,7 @@ inner_img_width = math.floor(inner_img_height * 0.7) def get_imagefont(name, size): + """Loads an ImageFont based on config""" try: config = settings.FONTS[name] path = os.path.join(settings.FONT_DIR, config["directory"], config["filename"]) @@ -49,6 +49,7 @@ def get_imagefont(name, size): def get_font(weight, size=28): + """Gets a custom font with the given weight and size""" font = get_imagefont(DEFAULT_FONT, size) try: diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 75987ae9b..591a3b3b3 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -50,6 +50,7 @@ PREVIEW_DEFAULT_COVER_COLOR = env.str("PREVIEW_DEFAULT_COVER_COLOR", "#002549") PREVIEW_DEFAULT_FONT = env.str("PREVIEW_DEFAULT_FONT", "Source Han Sans") FONTS = { + # pylint: disable=line-too-long "Source Han Sans": { "directory": "source_han_sans", "filename": "SourceHanSans-VF.ttf.ttc",