Skip to content

Commit

Permalink
black: Format complex condition
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Oct 30, 2024
1 parent 0a75315 commit 9d46349
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/croniter/croniter.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,13 +837,18 @@ def is_leap(year):
def value_alias(cls, val, field_index, len_expressions=UNIX_CRON_LEN):
if isinstance(len_expressions, (list, dict, tuple, set)):
len_expressions = len(len_expressions)

is_std_cron = len_expressions == UNIX_CRON_LEN
is_sec_cron = len_expressions == SECOND_CRON_LEN
is_year_cron = len_expressions == YEAR_CRON_LEN

if val in cls.LOWMAP[field_index] and not (
# do not support 0 as a month either for classical 5 fields cron,
# 6fields second repeat form or 7 fields year form
# but still let conversion happen if day field is shifted
(field_index in [DAY_FIELD, MONTH_FIELD] and len_expressions == UNIX_CRON_LEN) or
(field_index in [MONTH_FIELD, DOW_FIELD] and len_expressions == SECOND_CRON_LEN) or
(field_index in [DAY_FIELD, MONTH_FIELD, DOW_FIELD] and len_expressions == YEAR_CRON_LEN)
(field_index in [DAY_FIELD, MONTH_FIELD] and is_std_cron)
or (field_index in [MONTH_FIELD, DOW_FIELD] and is_sec_cron)
or (field_index in [DAY_FIELD, MONTH_FIELD, DOW_FIELD] and is_year_cron)
):
val = cls.LOWMAP[field_index][val]
return val
Expand Down

0 comments on commit 9d46349

Please sign in to comment.