code quality improvements

This commit is contained in:
Ace
2024-05-11 23:25:40 +02:00
parent 6a825d431c
commit 9346fcf750
6 changed files with 14 additions and 15 deletions

View File

@@ -14,7 +14,7 @@ import inkycal.modules.inkycal_stocks
import inkycal.modules.inkycal_webshot
import inkycal.modules.inkycal_xkcd
import inkycal.modules.inkycal_fullweather
import inkycal.modules.inkycal_mawaqit
# Main file
from inkycal.main import Inkycal
import inkycal.modules.inkycal_stocks

View File

@@ -2,13 +2,11 @@
Inkycal ePaper driving functions
Copyright by aceisace
"""
import os
from importlib import import_module
import PIL
from PIL import Image
from inkycal.custom import top_level
from inkycal.display.supported_models import supported_models
@@ -199,9 +197,7 @@ class Display:
>>> Display.get_display_names()
"""
driver_files = top_level + '/inkycal/display/drivers/'
drivers = [i for i in os.listdir(driver_files) if i.endswith(".py") and not i.startswith("__") and "_" in i]
return drivers
return supported_models.keys()
if __name__ == '__main__':

View File

@@ -28,8 +28,6 @@ THE SOFTWARE.
"""
import logging
import os
import subprocess
import sys
import time
@@ -128,4 +126,3 @@ implementation = RaspberryPi()
for func in [x for x in dir(implementation) if not x.startswith('_')]:
setattr(sys.modules[__name__], func, getattr(implementation, func))

View File

@@ -109,7 +109,7 @@ class Calendar(inkycal_module):
# Allocate space for month-names, weekdays etc.
month_name_height = int(im_height * 0.10)
text_bbox_height = self.font.getbbox("hg")
weekdays_height = int((text_bbox_height[3] - text_bbox_height[1])* 1.25)
weekdays_height = int((text_bbox_height[3] - text_bbox_height[1]) * 1.25)
logger.debug(f"month_name_height: {month_name_height}")
logger.debug(f"weekdays_height: {weekdays_height}")
@@ -265,7 +265,7 @@ class Calendar(inkycal_module):
# find out how many lines can fit at max in the event section
line_spacing = 2
text_bbox_height = self.font.getbbox("hg")
line_height = text_bbox_height[3] + line_spacing
line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing
max_event_lines = events_height // (line_height + line_spacing)
# generate list of coordinates for each line
@@ -326,7 +326,7 @@ class Calendar(inkycal_module):
(icon_width, icon_height),
radius=6,
thickness=1,
shrinkage=(0.4, 0.2),
shrinkage=(0, 0),
)
# Filter upcoming events until 4 weeks in the future