mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-11 01:35:28 +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 os
|
||||||
import urllib
|
import urllib
|
||||||
import logging
|
import logging
|
||||||
|
@ -10,15 +11,18 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def download_file(url, destination):
|
def download_file(url, destination):
|
||||||
|
"""Downloads a file to the given path"""
|
||||||
try:
|
try:
|
||||||
stream = urllib.request.urlopen(url)
|
with urllib.request.urlopen(url) as stream:
|
||||||
with open(destination, "b+w") as f:
|
with open(destination, "b+w") as outfile:
|
||||||
f.write(stream.read())
|
outfile.write(stream.read())
|
||||||
except (urllib.error.HTTPError, urllib.error.URLError):
|
except (urllib.error.HTTPError, urllib.error.URLError):
|
||||||
logger.error("Failed to download file %s", url)
|
logger.error("Failed to download file %s", url)
|
||||||
|
|
||||||
|
|
||||||
class BookwyrmConfig(AppConfig):
|
class BookwyrmConfig(AppConfig):
|
||||||
|
"""Handles additional configuration"""
|
||||||
|
|
||||||
name = "bookwyrm"
|
name = "bookwyrm"
|
||||||
verbose_name = "BookWyrm"
|
verbose_name = "BookWyrm"
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import os
|
||||||
import textwrap
|
import textwrap
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
import urllib
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import colorsys
|
import colorsys
|
||||||
|
@ -36,6 +35,7 @@ inner_img_width = math.floor(inner_img_height * 0.7)
|
||||||
|
|
||||||
|
|
||||||
def get_imagefont(name, size):
|
def get_imagefont(name, size):
|
||||||
|
"""Loads an ImageFont based on config"""
|
||||||
try:
|
try:
|
||||||
config = settings.FONTS[name]
|
config = settings.FONTS[name]
|
||||||
path = os.path.join(settings.FONT_DIR, config["directory"], config["filename"])
|
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):
|
def get_font(weight, size=28):
|
||||||
|
"""Gets a custom font with the given weight and size"""
|
||||||
font = get_imagefont(DEFAULT_FONT, size)
|
font = get_imagefont(DEFAULT_FONT, size)
|
||||||
|
|
||||||
try:
|
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")
|
PREVIEW_DEFAULT_FONT = env.str("PREVIEW_DEFAULT_FONT", "Source Han Sans")
|
||||||
|
|
||||||
FONTS = {
|
FONTS = {
|
||||||
|
# pylint: disable=line-too-long
|
||||||
"Source Han Sans": {
|
"Source Han Sans": {
|
||||||
"directory": "source_han_sans",
|
"directory": "source_han_sans",
|
||||||
"filename": "SourceHanSans-VF.ttf.ttc",
|
"filename": "SourceHanSans-VF.ttf.ttc",
|
||||||
|
|
Loading…
Reference in a new issue