diff --git a/jrnl/journals/FolderJournal.py b/jrnl/journals/FolderJournal.py index 684c4c2e5..cc16926c2 100644 --- a/jrnl/journals/FolderJournal.py +++ b/jrnl/journals/FolderJournal.py @@ -18,7 +18,6 @@ DIGIT_PATTERN = "[0123456789]" YEAR_PATTERN = DIGIT_PATTERN * 4 MONTH_PATTERN = "[01]" + DIGIT_PATTERN -DAY_PATTERN = "[0-3][0-9].(txt|md)" class Folder(Journal): @@ -35,7 +34,7 @@ def open(self) -> "Folder": self.entries = [] if os.path.exists(self.config["journal"]): - filenames = Folder._get_files(self.config["journal"]) + filenames = Folder._get_files(self, self.config["journal"]) for filename in filenames: with codecs.open(filename, "r", "utf-8") as f: journal = f.read() @@ -64,7 +63,7 @@ def write(self) -> None: self.config["journal"], d.strftime("%Y"), d.strftime("%m"), - d.strftime("%d") + ".txt", + d.strftime("%d") + "." + self.config["extension"], ) dirname = os.path.dirname(filename) # create directory if it doesn't exist @@ -122,12 +121,12 @@ def parse_editable_str(self, edited: str) -> None: self.entries = mod_entries @staticmethod - def _get_files(journal_path: str) -> list[str]: + def _get_files(self, journal_path: str) -> list[str]: """Searches through sub directories starting with journal_path and find all text files that look like entries""" for year_folder in Folder._get_year_folders(pathlib.Path(journal_path)): for month_folder in Folder._get_month_folders(year_folder): - yield from Folder._get_day_files(month_folder) + yield from Folder._get_day_files(self, month_folder) @staticmethod def _get_year_folders(path: pathlib.Path) -> list[pathlib.Path]: @@ -144,8 +143,9 @@ def _get_month_folders(path: pathlib.Path) -> list[pathlib.Path]: return @staticmethod - def _get_day_files(path: pathlib.Path) -> list[str]: + def _get_day_files(self, path: pathlib.Path) -> list[str]: for child in path.iterdir(): + DAY_PATTERN = "[0-3][0-9].(txt|md|" + self.config["extension"] + ")" match = re.search(DAY_PATTERN, str(child)) if ( match is not None