code quality improvements
This commit is contained in:
parent
6a825d431c
commit
9346fcf750
@ -14,7 +14,7 @@ import inkycal.modules.inkycal_stocks
|
|||||||
import inkycal.modules.inkycal_webshot
|
import inkycal.modules.inkycal_webshot
|
||||||
import inkycal.modules.inkycal_xkcd
|
import inkycal.modules.inkycal_xkcd
|
||||||
import inkycal.modules.inkycal_fullweather
|
import inkycal.modules.inkycal_fullweather
|
||||||
|
import inkycal.modules.inkycal_mawaqit
|
||||||
|
|
||||||
# Main file
|
# Main file
|
||||||
from inkycal.main import Inkycal
|
from inkycal.main import Inkycal
|
||||||
import inkycal.modules.inkycal_stocks
|
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
Inkycal ePaper driving functions
|
Inkycal ePaper driving functions
|
||||||
Copyright by aceisace
|
Copyright by aceisace
|
||||||
"""
|
"""
|
||||||
import os
|
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
|
||||||
import PIL
|
import PIL
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from inkycal.custom import top_level
|
|
||||||
from inkycal.display.supported_models import supported_models
|
from inkycal.display.supported_models import supported_models
|
||||||
|
|
||||||
|
|
||||||
@ -199,9 +197,7 @@ class Display:
|
|||||||
|
|
||||||
>>> Display.get_display_names()
|
>>> Display.get_display_names()
|
||||||
"""
|
"""
|
||||||
driver_files = top_level + '/inkycal/display/drivers/'
|
return supported_models.keys()
|
||||||
drivers = [i for i in os.listdir(driver_files) if i.endswith(".py") and not i.startswith("__") and "_" in i]
|
|
||||||
return drivers
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -28,8 +28,6 @@ THE SOFTWARE.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -128,4 +126,3 @@ implementation = RaspberryPi()
|
|||||||
|
|
||||||
for func in [x for x in dir(implementation) if not x.startswith('_')]:
|
for func in [x for x in dir(implementation) if not x.startswith('_')]:
|
||||||
setattr(sys.modules[__name__], func, getattr(implementation, func))
|
setattr(sys.modules[__name__], func, getattr(implementation, func))
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ class Calendar(inkycal_module):
|
|||||||
# Allocate space for month-names, weekdays etc.
|
# Allocate space for month-names, weekdays etc.
|
||||||
month_name_height = int(im_height * 0.10)
|
month_name_height = int(im_height * 0.10)
|
||||||
text_bbox_height = self.font.getbbox("hg")
|
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"month_name_height: {month_name_height}")
|
||||||
logger.debug(f"weekdays_height: {weekdays_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
|
# find out how many lines can fit at max in the event section
|
||||||
line_spacing = 2
|
line_spacing = 2
|
||||||
text_bbox_height = self.font.getbbox("hg")
|
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)
|
max_event_lines = events_height // (line_height + line_spacing)
|
||||||
|
|
||||||
# generate list of coordinates for each line
|
# generate list of coordinates for each line
|
||||||
@ -326,7 +326,7 @@ class Calendar(inkycal_module):
|
|||||||
(icon_width, icon_height),
|
(icon_width, icon_height),
|
||||||
radius=6,
|
radius=6,
|
||||||
thickness=1,
|
thickness=1,
|
||||||
shrinkage=(0.4, 0.2),
|
shrinkage=(0, 0),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Filter upcoming events until 4 weeks in the future
|
# Filter upcoming events until 4 weeks in the future
|
||||||
|
@ -28,7 +28,7 @@ tests = [
|
|||||||
"padding_x": 10,
|
"padding_x": 10,
|
||||||
"padding_y": 10,
|
"padding_y": 10,
|
||||||
"fontsize": 12,
|
"fontsize": 12,
|
||||||
"language": "en"
|
"language": "de"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -6,10 +6,15 @@ import logging
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from inkycal.modules import Webshot
|
from inkycal.modules import Webshot
|
||||||
|
from inkycal.modules.inky_image import Inkyimage
|
||||||
|
from tests import Config
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
preview = Inkyimage.preview
|
||||||
|
merge = Inkyimage.merge
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
{
|
{
|
||||||
"position": 1,
|
"position": 1,
|
||||||
@ -60,6 +65,7 @@ class TestWebshot(unittest.TestCase):
|
|||||||
for test in tests:
|
for test in tests:
|
||||||
logger.info(f'test {tests.index(test) + 1} generating image..')
|
logger.info(f'test {tests.index(test) + 1} generating image..')
|
||||||
module = Webshot(test)
|
module = Webshot(test)
|
||||||
module.generate_image()
|
im_black, im_colour = module.generate_image()
|
||||||
|
if Config.USE_PREVIEW:
|
||||||
|
preview(merge(im_black, im_colour))
|
||||||
logger.info('OK')
|
logger.info('OK')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user