diff --git a/edtf/natlang/en.py b/edtf/natlang/en.py index 49b04f3..97230db 100644 --- a/edtf/natlang/en.py +++ b/edtf/natlang/en.py @@ -1,4 +1,5 @@ """Utilities to derive an EDTF string from an (English) natural language string.""" + import functools import re from datetime import datetime @@ -52,7 +53,7 @@ REJECT_RULES = re.compile(r".*dynasty.*") # Don't parse '23rd Dynasty' to 'uuuu-uu-23' -@functools.lru_cache() +@functools.lru_cache def text_to_edtf(text: str) -> Optional[str]: """ Generate EDTF string equivalent of a given natural language date string. @@ -133,7 +134,7 @@ def text_to_edtf(text: str) -> Optional[str]: return result -@functools.lru_cache() +@functools.lru_cache def text_to_edtf_date(text: str) -> Optional[str]: """ Return EDTF string equivalent of a given natural language date string. diff --git a/edtf/parser/parser_classes.py b/edtf/parser/parser_classes.py index eada1f9..ad690fb 100644 --- a/edtf/parser/parser_classes.py +++ b/edtf/parser/parser_classes.py @@ -98,10 +98,6 @@ class EDTFObject: parser = None - def __init__(self, *args, **kwargs): - errmsg: str = f"{type(self).__name__}.__init__(*{args}, **{kwargs})" - raise NotImplementedError(f"{errmsg} is not implemented.") - @classmethod def set_parser(cls, p): cls.parser = p @@ -288,6 +284,7 @@ def set_year(self, y: int): def get_year(self) -> int: return self._year + year = property(get_year, set_year) def set_month(self, m: Optional[int]): @@ -297,6 +294,7 @@ def set_month(self, m: Optional[int]): def get_month(self) -> Optional[int]: return self._month + month = property(get_month, set_month) def __str__(self): @@ -932,8 +930,9 @@ def __str__(self): return result - def set_year(self, y): # Year can be None. + def set_year(self, y): # Year can be None. self._year = y + year = property(Date.get_year, set_year) def _precise_year(self, lean: str):