Skip to content

Commit

Permalink
black: Special formatting for ALHPAS / *_FIELDS (#121)
Browse files Browse the repository at this point in the history
* black: Special formatting for ALHPAS / *_FIELDS

* better format

Co-authored-by: Evan Purkhiser <evanpurkhiser@gmail.com>

---------

Co-authored-by: kiorky <kiorky@cryptelium.net>
  • Loading branch information
evanpurkhiser and kiorky authored Oct 30, 2024
1 parent dbcc418 commit 6a6ccc8
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/croniter/croniter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+$")
Expand All @@ -93,16 +113,7 @@ def is_32bit():
hash_expression_re = re.compile(
r"^(?P<hash_type>h|r)(\((?P<range_begin>\d+)-(?P<range_end>\d+)\))?(\/(?P<divisor>\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,
Expand Down

0 comments on commit 6a6ccc8

Please sign in to comment.