mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
Fix handling for complex extensions
This also handles additional input for extensions in case the user isn't fully aware of how extensions work
This commit is contained in:
parent
8e5b5b6c19
commit
cbf4ed5c35
1 changed files with 6 additions and 5 deletions
|
@ -17,6 +17,7 @@ if TYPE_CHECKING:
|
||||||
DIGIT_PATTERN = "[0123456789]"
|
DIGIT_PATTERN = "[0123456789]"
|
||||||
YEAR_PATTERN = DIGIT_PATTERN * 4
|
YEAR_PATTERN = DIGIT_PATTERN * 4
|
||||||
MONTH_PATTERN = "[01]" + DIGIT_PATTERN
|
MONTH_PATTERN = "[01]" + DIGIT_PATTERN
|
||||||
|
DAY_PATTERN = "[0-3][0-9]"
|
||||||
|
|
||||||
DEFAULT_EXTENSION = ".txt"
|
DEFAULT_EXTENSION = ".txt"
|
||||||
|
|
||||||
|
@ -148,15 +149,15 @@ class Folder(Journal):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_day_files(path: pathlib.Path, extension: str) -> list[str]:
|
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 + extension):
|
||||||
for child in path.glob(DAY_PATTERN):
|
day = str(child.name).replace(extension, "")
|
||||||
if (
|
if (
|
||||||
int(child.stem) > 0
|
int(day) > 0
|
||||||
and int(child.stem) <= 31
|
and int(day) <= 31
|
||||||
and time.is_valid_date(
|
and time.is_valid_date(
|
||||||
year=int(path.parent.name),
|
year=int(path.parent.name),
|
||||||
month=int(path.name),
|
month=int(path.name),
|
||||||
day=int(child.stem),
|
day=int(day),
|
||||||
)
|
)
|
||||||
and child.is_file()
|
and child.is_file()
|
||||||
):
|
):
|
||||||
|
|
Loading…
Add table
Reference in a new issue