mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 08:36:32 +00:00
Fix linting and formatting
This commit is contained in:
parent
a1a3aa45f4
commit
0c53f4e003
3 changed files with 10 additions and 4 deletions
|
@ -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"
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue