Change the contract, just take the actual filename, not the file path

This commit is contained in:
Trenton H
2026-01-28 14:24:14 -08:00
parent dfe0012872
commit 7afc8ceb24
3 changed files with 3 additions and 6 deletions

View File

@@ -4,7 +4,6 @@ from abc import ABC
from abc import abstractmethod
from collections.abc import Iterator
from dataclasses import dataclass
from pathlib import Path
import dateparser
@@ -90,7 +89,7 @@ class DateParserPluginBase(ABC):
return None
@abstractmethod
def parse(self, filename: Path, content: str) -> Iterator[datetime.datetime]:
def parse(self, filename: str, content: str) -> Iterator[datetime.datetime]:
"""
Parses a document's filename and content, yielding valid datetime objects.
"""

View File

@@ -1,7 +1,6 @@
import datetime
import re
from collections.abc import Iterator
from pathlib import Path
from re import Match
from documents.plugins.date_parsing.base import DateParserPluginBase
@@ -51,7 +50,7 @@ class RegexDateParserPlugin(DateParserPluginBase):
if date is not None:
yield date
def parse(self, filename: Path, content: str) -> Iterator[datetime.datetime]:
def parse(self, filename: str, content: str) -> Iterator[datetime.datetime]:
"""
Implementation of the abstract parse method.
@@ -59,7 +58,7 @@ class RegexDateParserPlugin(DateParserPluginBase):
"""
if self.config.filename_date_order:
yield from self._process_content(
filename.name,
filename,
self.config.filename_date_order,
)

View File

@@ -213,7 +213,6 @@ class TestFilterDate:
@pytest.mark.date_parsing
@pytest.mark.regex_date_parser
class TestRegexDateParser:
@pytest.mark.parametrize(
("filename", "content", "expected"),