Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): do not raise error for bad date_from_meta.default_time value and fallback to default #300

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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