implementing formatting text
This commit is contained in:
parent
6be934e374
commit
0c4c41ff84
@ -5,7 +5,7 @@ from pathlib import Path
|
||||
import requests
|
||||
from ics import Calendar, Event
|
||||
|
||||
from ..utils import config, error, prompt, ICS_FILE
|
||||
from ..utils import config, error, prompt, ICS_FILE, date
|
||||
from ..feeds import *
|
||||
|
||||
|
||||
@ -69,8 +69,19 @@ class Routine:
|
||||
|
||||
@staticmethod
|
||||
def get_event_string(event: Event) -> str:
|
||||
return f""
|
||||
event_config = config.get_field("messages", {}).get(event.name, {})
|
||||
if not len(event_config):
|
||||
return ""
|
||||
|
||||
message = event_config.get("message", "")
|
||||
|
||||
data = date.event_formatting_values(event, "de")
|
||||
|
||||
for key, value in data.items():
|
||||
message = message.replace(f"{{{key}}}", value)
|
||||
|
||||
return message.strip()
|
||||
|
||||
def run(self):
|
||||
pass
|
||||
|
||||
|
@ -10,10 +10,5 @@ class Development(Routine):
|
||||
calendar = self.get_ics()
|
||||
|
||||
for event in calendar.events:
|
||||
print(event.name, date.event_formatting_values(event, "de"))
|
||||
break
|
||||
|
||||
event_description = f"""
|
||||
Wir treffen uns {event.begin.humanize(locale="de")} zum {event.name}."""
|
||||
print(event_description.strip())
|
||||
print()
|
||||
print(f"Event: {event.name}")
|
||||
print(self.get_event_string(event))
|
||||
|
@ -7,13 +7,22 @@ from . import PROGRAM_DATA_DIR, PROGRAM_NAME
|
||||
|
||||
logger = logging.getLogger("config")
|
||||
_config: dict = {
|
||||
"ics_url": "",
|
||||
|
||||
"locale": "en",
|
||||
"date_format": "%Y-%m-%d %H:%M:%S",
|
||||
"time_format": "%H:%M",
|
||||
"time_format_full_hour": "%H",
|
||||
|
||||
"weekday_translations": {},
|
||||
"months_translations": {},
|
||||
|
||||
"active_feeds": [
|
||||
"mastodon",
|
||||
"twitter",
|
||||
],
|
||||
"weekday_translations": {},
|
||||
"months_translations": {},
|
||||
"ics_url": "",
|
||||
|
||||
|
||||
"mastodon": {},
|
||||
"twitter": {},
|
||||
"lemmy": {},
|
||||
|
Loading…
Reference in New Issue
Block a user