From 6a6ccc81151ce8765a379850ed498e43b892f60b Mon Sep 17 00:00:00 2001 From: Evan Purkhiser Date: Wed, 30 Oct 2024 14:44:26 -0400 Subject: [PATCH] black: Special formatting for ALHPAS / *_FIELDS (#121) * black: Special formatting for ALHPAS / *_FIELDS * better format Co-authored-by: Evan Purkhiser --------- Co-authored-by: kiorky --- src/croniter/croniter.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/croniter/croniter.py b/src/croniter/croniter.py index e0bc0b1..d22379e 100644 --- a/src/croniter/croniter.py +++ b/src/croniter/croniter.py @@ -75,9 +75,29 @@ def is_32bit(): EPOCH = datetime.datetime.fromtimestamp(0) -M_ALPHAS = {"jan": 1, "feb": 2, "mar": 3, "apr": 4, "may": 5, "jun": 6, - "jul": 7, "aug": 8, "sep": 9, "oct": 10, "nov": 11, "dec": 12} -DOW_ALPHAS = {"sun": 0, "mon": 1, "tue": 2, "wed": 3, "thu": 4, "fri": 5, "sat": 6} + +# fmt: off +M_ALPHAS = { + "jan": 1, "feb": 2, "mar": 3, "apr": 4, # noqa: E241 + "may": 5, "jun": 6, "jul": 7, "aug": 8, # noqa: E241 + "sep": 9, "oct": 10, "nov": 11, "dec": 12, +} +DOW_ALPHAS = { + "sun": 0, "mon": 1, "tue": 2, "wed": 3, "thu": 4, "fri": 5, "sat": 6 +} + +MINUTE_FIELD = 0 +HOUR_FIELD = 1 +DAY_FIELD = 2 +MONTH_FIELD = 3 +DOW_FIELD = 4 +SECOND_FIELD = 5 +YEAR_FIELD = 6 + +UNIX_FIELDS = (MINUTE_FIELD, HOUR_FIELD, DAY_FIELD, MONTH_FIELD, DOW_FIELD) # noqa: E222 +SECOND_FIELDS = (MINUTE_FIELD, HOUR_FIELD, DAY_FIELD, MONTH_FIELD, DOW_FIELD, SECOND_FIELD) # noqa: E222 +YEAR_FIELDS = (MINUTE_FIELD, HOUR_FIELD, DAY_FIELD, MONTH_FIELD, DOW_FIELD, SECOND_FIELD, YEAR_FIELD) # noqa: E222 +# fmt: on step_search_re = re.compile(r"^([^-]+)-([^-/]+)(/(\d+))?$") only_int_re = re.compile(r"^\d+$") @@ -93,16 +113,7 @@ def is_32bit(): hash_expression_re = re.compile( r"^(?Ph|r)(\((?P\d+)-(?P\d+)\))?(\/(?P\d+))?$" ) -MINUTE_FIELD = 0 -HOUR_FIELD = 1 -DAY_FIELD = 2 -MONTH_FIELD = 3 -DOW_FIELD = 4 -SECOND_FIELD = 5 -YEAR_FIELD = 6 -UNIX_FIELDS = (MINUTE_FIELD, HOUR_FIELD, DAY_FIELD, MONTH_FIELD, DOW_FIELD) -SECOND_FIELDS = (MINUTE_FIELD, HOUR_FIELD, DAY_FIELD, MONTH_FIELD, DOW_FIELD, SECOND_FIELD) -YEAR_FIELDS = (MINUTE_FIELD, HOUR_FIELD, DAY_FIELD, MONTH_FIELD, DOW_FIELD, SECOND_FIELD, YEAR_FIELD) + CRON_FIELDS = { "unix": UNIX_FIELDS, "second": SECOND_FIELDS,