Work in progress for release v1.7/1.8

This is a refactoring of the entire Inky-Calendar software and is work in progress. The reason for uploading is to test if everything works fine. Please do not attempt to use/install this software as it can potentially break your system. If you have any improvement ideas, you're most welcome to mention them in the Issues section. Thanks!
This commit is contained in:
Ace
2019-10-21 07:54:19 +02:00
committed by GitHub
parent 93426b3dea
commit e3a4997fdb
28 changed files with 1118 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
"""Add rss-feeds at the bottom section of the Calendar"""
import feedparser
from random import shuffle
from settings import *
from configuration import *
"""Find out how many lines can fit at max in the bottom section"""
lines = bottom_section_height // line_height
"""Create and fill a dictionary of the positions of each line"""
line_pos = {}
for i in range(lines):
y = bottom_section_offset + i * line_height
line_pos['pos' + str(i+1)] = (x_padding, y)
if bottom_section == "RSS" and rss_feeds != []:
"""Parse the RSS-feed titles & summaries and save them to a list"""
rss_feed = []
for feeds in rss_feeds:
text = feedparser.parse(feeds)
for posts in text.entries:
rss_feed.append('{0}: {1}'.format(posts.title, posts.summary))
del rss_feed[lines:]
shuffle(rss_feed)
"""Check the lenght of each feed. Wrap the text if it doesn't fit on one line"""
flatten = lambda z: [x for y in z for x in y]
filtered, counter = [], 0
for posts in rss_feed:
wrapped = text_wrap(posts)
counter += len(filtered) + len(wrapped)
if counter < lines:
filtered.append(wrapped)
filtered = flatten(filtered)
## for i in lines: # Show line lenght and content of each line
## print(i, ' ' * (line-len(i)),'| height: ',default.getsize(i)[1])
"""Write the correctly formatted text on the display"""
for i in range(len(filtered)):
write_text(display_width, default.getsize('hg')[1],
' '+filtered[i], line_pos['pos'+str(i+1)], alignment= 'left')
image.crop((0,bottom_section_offset, display_width, display_height)).save(
'rss.png')
del filtered, rss_feed