mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-28 22:59:03 -06:00
Change the contract, just take the actual filename, not the file path
This commit is contained in:
@@ -4,7 +4,6 @@ from abc import ABC
|
|||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import dateparser
|
import dateparser
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ class DateParserPluginBase(ABC):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@abstractmethod
|
@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.
|
Parses a document's filename and content, yielding valid datetime objects.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
from pathlib import Path
|
|
||||||
from re import Match
|
from re import Match
|
||||||
|
|
||||||
from documents.plugins.date_parsing.base import DateParserPluginBase
|
from documents.plugins.date_parsing.base import DateParserPluginBase
|
||||||
@@ -51,7 +50,7 @@ class RegexDateParserPlugin(DateParserPluginBase):
|
|||||||
if date is not None:
|
if date is not None:
|
||||||
yield date
|
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.
|
Implementation of the abstract parse method.
|
||||||
|
|
||||||
@@ -59,7 +58,7 @@ class RegexDateParserPlugin(DateParserPluginBase):
|
|||||||
"""
|
"""
|
||||||
if self.config.filename_date_order:
|
if self.config.filename_date_order:
|
||||||
yield from self._process_content(
|
yield from self._process_content(
|
||||||
filename.name,
|
filename,
|
||||||
self.config.filename_date_order,
|
self.config.filename_date_order,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -213,7 +213,6 @@ class TestFilterDate:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.date_parsing
|
@pytest.mark.date_parsing
|
||||||
@pytest.mark.regex_date_parser
|
|
||||||
class TestRegexDateParser:
|
class TestRegexDateParser:
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("filename", "content", "expected"),
|
("filename", "content", "expected"),
|
||||||
|
|||||||
Reference in New Issue
Block a user