Skip to content

Commit

Permalink
fix(config): do not raise error for bad date_from_meta.default_time v…
Browse files Browse the repository at this point in the history
…alue and fallback to default

Closes #290
  • Loading branch information
Guts committed Jun 23, 2024
1 parent 09e4ce4 commit 38c477f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions mkdocs_rss_plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# ##################################

# standard
from datetime import datetime
from typing import Union

# 3rd party
Expand All @@ -25,7 +24,7 @@ class _DateFromMeta(Config):
as_creation = config_options.Type(Union[bool, str], default="git")
as_update = config_options.Type(Union[bool, str], default="git")
datetime_format = config_options.Type(str, default="%Y-%m-%d %H:%M")
default_time = config_options.Type(str, default=datetime.min.strftime("%H:%M"))
default_time = config_options.Type(str, default="00:00")
default_timezone = config_options.Type(str, default="UTC")


Expand Down
8 changes: 4 additions & 4 deletions mkdocs_rss_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from jinja2 import Environment, FileSystemLoader, select_autoescape
from mkdocs.config import config_options
from mkdocs.config.defaults import MkDocsConfig
from mkdocs.exceptions import PluginError
from mkdocs.plugins import BasePlugin, event_priority, get_plugin_logger
from mkdocs.structure.files import Files
from mkdocs.structure.pages import Page
Expand Down Expand Up @@ -169,12 +168,13 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig:
self.config.date_from_meta.default_time = datetime.strptime(
self.config.date_from_meta.default_time, "%H:%M"
)
except ValueError as err:
raise PluginError(
except (TypeError, ValueError) as err:
logger.warning(
"Config error: `date_from_meta.default_time` value "
f"'{self.config.date_from_meta.default_time}' format doesn't match the "
f"expected format %H:%M. Trace: {err}"
f"expected format %H:%M. Fallback to the default value. Trace: {err}"
)
self.config.date_from_meta.default_time = "00:00"

if self.config.use_git:
logger.debug(
Expand Down

0 comments on commit 38c477f

Please sign in to comment.