Read calendards URL from .cals file

This commit is contained in:
nemunaire 2022-08-14 19:55:12 +02:00
commit 5acdf32ae7
3 changed files with 11 additions and 4 deletions

View file

@ -5,7 +5,7 @@ from PIL import Image, ImageDraw, ImageFont
class Config:
def __init__(self):
def __init__(self, cals_file_list=".cals"):
if os.path.exists('/usr/share/fonts/source-pro/'):
self.fnt_R_path = "/usr/share/fonts/source-pro/SourceSansPro-Regular.otf"
self.fnt_RI_path = "/usr/share/fonts/source-pro/SourceSansPro-It.otf"
@ -19,6 +19,13 @@ class Config:
self.fnt_RI_path = "/usr/share/fonts/TTF/LinBiolinum_RIah.ttf"
self.fnt_RB_path = "/usr/share/fonts/TTF/LinBiolinum_RBah.ttf"
try:
with open(cals_file_list) as f:
self.cals = [c for c in f.read().split("\n") if len(c) > 0]
except:
print("No calendar found. Please create a file " + cals_file_list)
self.cals = []
self.css_overlay = NamedTemporaryFile()
with open(self.css_overlay.name, 'w') as f:
f.write('''