mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-24 07:30:12 +01:00
Fixed blog plugin compatibility with Python < 3.9
This commit is contained in:
parent
4c6b004fe4
commit
f2512ded4a
@ -18,28 +18,28 @@
|
|||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
# IN THE SOFTWARE.
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
from collections import UserDict
|
|
||||||
from datetime import date, datetime, time
|
from datetime import date, datetime, time
|
||||||
from mkdocs.config.base import BaseConfigOption, Config, ValidationError
|
from mkdocs.config.base import BaseConfigOption, Config, ValidationError
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Classes
|
# Classes
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
# Date dictionary
|
# Date dictionary
|
||||||
class DateDict(UserDict[str, datetime]):
|
class DateDict(Dict[str, datetime]):
|
||||||
|
|
||||||
# Initialize date dictionary
|
# Initialize date dictionary
|
||||||
def __init__(self, data: dict):
|
def __init__(self, data: dict):
|
||||||
super().__init__(data)
|
super().__init__(data)
|
||||||
|
|
||||||
# Initialize date of creation
|
# Ensure presence of `date.created`
|
||||||
if "created" in data:
|
|
||||||
self.created: datetime = data["created"]
|
self.created: datetime = data["created"]
|
||||||
|
|
||||||
|
# Allow attribute access
|
||||||
def __getattr__(self, name: str):
|
def __getattr__(self, name: str):
|
||||||
if name in self.data:
|
if name in self:
|
||||||
return self.data[name]
|
return self[name]
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -18,28 +18,28 @@
|
|||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
# IN THE SOFTWARE.
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
from collections import UserDict
|
|
||||||
from datetime import date, datetime, time
|
from datetime import date, datetime, time
|
||||||
from mkdocs.config.base import BaseConfigOption, Config, ValidationError
|
from mkdocs.config.base import BaseConfigOption, Config, ValidationError
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Classes
|
# Classes
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
# Date dictionary
|
# Date dictionary
|
||||||
class DateDict(UserDict[str, datetime]):
|
class DateDict(Dict[str, datetime]):
|
||||||
|
|
||||||
# Initialize date dictionary
|
# Initialize date dictionary
|
||||||
def __init__(self, data: dict):
|
def __init__(self, data: dict):
|
||||||
super().__init__(data)
|
super().__init__(data)
|
||||||
|
|
||||||
# Initialize date of creation
|
# Ensure presence of `date.created`
|
||||||
if "created" in data:
|
|
||||||
self.created: datetime = data["created"]
|
self.created: datetime = data["created"]
|
||||||
|
|
||||||
|
# Allow attribute access
|
||||||
def __getattr__(self, name: str):
|
def __getattr__(self, name: str):
|
||||||
if name in self.data:
|
if name in self:
|
||||||
return self.data[name]
|
return self[name]
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user