From c86a1934f9c17dda47af7a3f3aee8f58e7564203 Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Tue, 11 Jun 2024 10:24:37 +0200 Subject: [PATCH] refacto(cleanup): remove python 3.9 related code and deps (timezone) --- .../{timezoner_py39.py => timezoner.py} | 0 mkdocs_rss_plugin/timezoner_pre39.py | 56 ------------------- mkdocs_rss_plugin/util.py | 4 +- requirements/base.txt | 1 - 4 files changed, 1 insertion(+), 60 deletions(-) rename mkdocs_rss_plugin/{timezoner_py39.py => timezoner.py} (100%) delete mode 100644 mkdocs_rss_plugin/timezoner_pre39.py diff --git a/mkdocs_rss_plugin/timezoner_py39.py b/mkdocs_rss_plugin/timezoner.py similarity index 100% rename from mkdocs_rss_plugin/timezoner_py39.py rename to mkdocs_rss_plugin/timezoner.py diff --git a/mkdocs_rss_plugin/timezoner_pre39.py b/mkdocs_rss_plugin/timezoner_pre39.py deleted file mode 100644 index 73ae7e5..0000000 --- a/mkdocs_rss_plugin/timezoner_pre39.py +++ /dev/null @@ -1,56 +0,0 @@ -#! python3 # noqa: E265 - - -""" - Manage timezones for pages date(time)s using pytz module. - Meant to be dropped when Python 3.8 reaches EOL. -""" - -# ############################################################################ -# ########## Libraries ############# -# ################################## - -# standard library -from datetime import datetime - -# 3rd party -import pytz -from mkdocs.plugins import get_plugin_logger - -# package -from mkdocs_rss_plugin.constants import MKDOCS_LOGGER_NAME - -# ############################################################################ -# ########## Globals ############# -# ################################ - - -logger = get_plugin_logger(MKDOCS_LOGGER_NAME) - - -# ############################################################################ -# ########## Functions ########### -# ################################ - - -def set_datetime_zoneinfo( - input_datetime: datetime, config_timezone: str = "UTC" -) -> datetime: - """Apply timezone to a naive datetime. - - :param input_datetime: offset-naive datetime - :type input_datetime: datetime - :param config_timezone: name of timezone as registered in IANA database, - defaults to "UTC". Example : Europe/Paris. - :type config_timezone: str, optional - - :return: offset-aware datetime - :rtype: datetime - """ - if input_datetime.tzinfo: - return input_datetime - elif not config_timezone: - return input_datetime.replace(tzinfo=pytz.utc) - else: - config_tz = pytz.timezone(config_timezone) - return config_tz.localize(input_datetime) diff --git a/mkdocs_rss_plugin/util.py b/mkdocs_rss_plugin/util.py index 6e56ade..e966fe0 100644 --- a/mkdocs_rss_plugin/util.py +++ b/mkdocs_rss_plugin/util.py @@ -31,9 +31,7 @@ from mkdocs_rss_plugin.integrations.theme_material_social_plugin import ( IntegrationMaterialSocialCards, ) - -# conditional imports -from mkdocs_rss_plugin.timezoner_py39 import set_datetime_zoneinfo +from mkdocs_rss_plugin.timezoner import set_datetime_zoneinfo # ############################################################################ # ########## Globals ############# diff --git a/requirements/base.txt b/requirements/base.txt index 1fa26c6..fc74df5 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -4,5 +4,4 @@ GitPython>=3.1,<3.2 mkdocs>=1.5,<2 -pytz==2022.* ; python_version < "3.9" tzdata==2024.* ; python_version >= "3.9" and sys_platform == "win32"