Skip to content

Commit

Permalink
Allow searching directory journal for markdown files. Partial fix for j…
Browse files Browse the repository at this point in the history
  • Loading branch information
thw26 committed Sep 1, 2023
1 parent 75b703d commit 628edd0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions jrnl/journals/FolderJournal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import codecs
import os
import pathlib
import re
from typing import TYPE_CHECKING

from jrnl import time
Expand All @@ -17,7 +18,7 @@
DIGIT_PATTERN = "[0123456789]"
YEAR_PATTERN = DIGIT_PATTERN * 4
MONTH_PATTERN = "[01]" + DIGIT_PATTERN
DAY_PATTERN = "[0123]" + DIGIT_PATTERN + ".txt"
DAY_PATTERN = "[0-3][0-9].(txt|md)"


class Folder(Journal):
Expand Down Expand Up @@ -144,9 +145,11 @@ def _get_month_folders(path: pathlib.Path) -> list[pathlib.Path]:

@staticmethod
def _get_day_files(path: pathlib.Path) -> list[str]:
for child in path.glob(DAY_PATTERN):
for child in path.iterdir():
match = re.search(DAY_PATTERN, str(child))
if (
int(child.stem) > 0
match is not None
and int(child.stem) > 0
and int(child.stem) <= 31
and time.is_valid_date(
year=int(path.parent.name),
Expand Down

0 comments on commit 628edd0

Please sign in to comment.