Skip to content

Commit

Permalink
Fix handling for complex extensions
Browse files Browse the repository at this point in the history
This also handles additional input for extensions in case the user
isn't fully aware of how extensions work
  • Loading branch information
wren committed Aug 24, 2024
1 parent 8e5b5b6 commit 7c8a166
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions jrnl/journals/FolderJournal.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DIGIT_PATTERN = "[0123456789]"
YEAR_PATTERN = DIGIT_PATTERN * 4
MONTH_PATTERN = "[01]" + DIGIT_PATTERN
DAY_PATTERN = "[0-3][0-9]"

DEFAULT_EXTENSION = ".txt"

Expand Down Expand Up @@ -148,15 +149,15 @@ def _get_month_folders(path: pathlib.Path) -> list[pathlib.Path]:

@staticmethod
def _get_day_files(path: pathlib.Path, extension: str) -> list[str]:
DAY_PATTERN = "[0-3][0-9]" + extension
for child in path.glob(DAY_PATTERN):
for child in path.glob(DAY_PATTERN + extension):
day = str(child.name).replace(extension, '')
if (
int(child.stem) > 0
and int(child.stem) <= 31
int(day) > 0
and int(day) <= 31
and time.is_valid_date(
year=int(path.parent.name),
month=int(path.name),
day=int(child.stem),
day=int(day),
)
and child.is_file()
):
Expand Down

0 comments on commit 7c8a166

Please sign in to comment.