-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Zeutschler/dev
Dev
- Loading branch information
Showing
16 changed files
with
1,015 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
# DateSpanLib - Copyright (c)2024, Thomas Zeutschler, MIT license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,37 @@ | ||
# DateSpanLib - Copyright (c)2024, Thomas Zeutschler, MIT license | ||
|
||
from abc import ABC, abstractmethod | ||
from datetime import datetime | ||
from dateutil.parser import parserinfo | ||
|
||
from datespanlib.date_span import DateSpan | ||
|
||
|
||
class DateTextLanguageParser(ABC): | ||
"""Base class for language specific date filter parsers.""" | ||
"""Base class for language specific date text parsing.""" | ||
|
||
@property | ||
@abstractmethod | ||
def language(self) -> str: | ||
"""Returns the ISO 639-1 language code of the parser.""" | ||
pass | ||
|
||
@abstractmethod | ||
def parse(self, text: str, parser_info: None | parserinfo = None) -> DateSpan | list[DateSpan]: | ||
def evaluate(self, text: str, parser_info: None | parserinfo = None) -> DateSpan | list[DateSpan]: | ||
""" | ||
Parses a date text string into a list of DateSpans, each containing a (`datetime`, `datetime`) time-span tuples. | ||
Arguments: | ||
text: The date text string to parse. | ||
parser_info: (optional) A dateutil.parser.parserinfo instance to use for parsing dates contained | ||
datespan_text. If not defined, the default parser of the dateutil library will be used. | ||
Returns: | ||
A list of DateSpan objects or None. If None is returned, the text could not be parsed. | ||
""" | ||
pass | ||
|
||
@property | ||
@abstractmethod | ||
def message(self) -> str: | ||
"""Returns information about the last failing parsing operation.""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.