some cleaning

This commit is contained in:
Stuce 2025-11-17 17:54:42 +01:00
parent f1ff6afdc8
commit acc66afebb

View file

@ -5,7 +5,7 @@ from caldav import DAVClient, Calendar, Principal, Todo
import configparser import configparser
def parseConfig(): def parseConfig() -> tuple[str, str, str, str]:
def passwordFromFile() -> str: def passwordFromFile() -> str:
calDavPasswordFile = config.get("calDAV", "passwordFile") calDavPasswordFile = config.get("calDAV", "passwordFile")
with open(calDavPasswordFile, "r") as file: with open(calDavPasswordFile, "r") as file:
@ -13,8 +13,8 @@ def parseConfig():
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("/etc/calDAVtoCSV/config.ini") config.read("/etc/calDAVtoCSV/config.ini")
calDavAddress = config.get("calDAV", "address") calDavAddress = config.get("calDAV", "address")
print(calDavAddress)
calDavUsername = config.get("calDAV", "username") calDavUsername = config.get("calDAV", "username")
caldavpwd = config.get("calDAV", "password", fallback=None) caldavpwd = config.get("calDAV", "password", fallback=None)
caldavpwd = caldavpwd if caldavpwd is not None else passwordFromFile() caldavpwd = caldavpwd if caldavpwd is not None else passwordFromFile()
@ -50,10 +50,6 @@ def fetch_10_next_todos_as_csv() -> str:
return csv return csv
def put(todos, uid):
item = filter(lambda todo: todo.icalendar_component["uid"] == uid, todos)
app = Flask(__name__) app = Flask(__name__)
@ -62,5 +58,6 @@ def send_events():
return fetch_10_next_todos_as_csv() return fetch_10_next_todos_as_csv()
# not suitable for production apparently, just for testing
if __name__ == "__main__": if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000) app.run(host="0.0.0.0", port=8000)