From f3e1573677d8786426d5cebb116a5040f69d17bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Sat, 3 Apr 2021 01:47:33 +0200 Subject: [PATCH] Minor cleanup in document loader. --- doc_manager.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc_manager.py b/doc_manager.py index fe1229d..8e53025 100644 --- a/doc_manager.py +++ b/doc_manager.py @@ -5,8 +5,9 @@ from datetime import datetime from typing import List import org_rw -from org_rw import OrgTime +from org_rw import OrgTime, OrgDoc +EXTENSIONS = ( ".org", ".org.txt" ) def is_today(ot: OrgTime): now = datetime.now() @@ -37,17 +38,19 @@ class Agenda: class DocumentManager: - def __init__(self, basepath): - self.basepath = basepath + docs: list[OrgDoc] + + def __init__(self, base_path: os.PathLike): + self.base_path = base_path def load(self): - top = os.path.abspath(self.basepath) + top = os.path.abspath(self.base_path) docs = [] for root, dirs, files in os.walk(top): for name in files: - if ".org" not in name: + if all(map(lambda ext: not name.endswith(ext), EXTENSIONS)): continue path = os.path.join(root, name)