main commit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-16 16:30:25 +09:00
parent 91c7e04474
commit 537e7b363f
1146 changed files with 45926 additions and 77196 deletions

View File

@@ -4,8 +4,9 @@ from __future__ import annotations
import re
from bisect import bisect, bisect_left
from collections import namedtuple
from collections.abc import Iterable
from datetime import datetime, timedelta, tzinfo
from typing import Any, Callable, Iterable, Mapping, Sequence, Union
from typing import Any, Callable, Mapping, Sequence
from kombu.utils.objects import cached_property
@@ -14,7 +15,7 @@ from celery import Celery
from . import current_app
from .utils.collections import AttributeDict
from .utils.time import (ffwd, humanize_seconds, localize, maybe_make_aware, maybe_timedelta, remaining, timezone,
weekday, yearmonth)
weekday)
__all__ = (
'ParseException', 'schedule', 'crontab', 'crontab_parser',
@@ -51,10 +52,7 @@ Argument event "{event}" is invalid, must be one of {all_events}.\
"""
Cronspec = Union[int, str, Iterable[int]]
def cronfield(s: Cronspec | None) -> Cronspec:
def cronfield(s: str) -> str:
return '*' if s is None else s
@@ -302,12 +300,9 @@ class crontab_parser:
i = int(s)
except ValueError:
try:
i = yearmonth(s)
i = weekday(s)
except KeyError:
try:
i = weekday(s)
except KeyError:
raise ValueError(f'Invalid weekday literal {s!r}.')
raise ValueError(f'Invalid weekday literal {s!r}.')
max_val = self.min_ + self.max_ - 1
if i > max_val:
@@ -398,8 +393,8 @@ class crontab(BaseSchedule):
present in ``month_of_year``.
"""
def __init__(self, minute: Cronspec = '*', hour: Cronspec = '*', day_of_week: Cronspec = '*',
day_of_month: Cronspec = '*', month_of_year: Cronspec = '*', **kwargs: Any) -> None:
def __init__(self, minute: str = '*', hour: str = '*', day_of_week: str = '*',
day_of_month: str = '*', month_of_year: str = '*', **kwargs: Any) -> None:
self._orig_minute = cronfield(minute)
self._orig_hour = cronfield(hour)
self._orig_day_of_week = cronfield(day_of_week)
@@ -413,26 +408,9 @@ class crontab(BaseSchedule):
self.month_of_year = self._expand_cronspec(month_of_year, 12, 1)
super().__init__(**kwargs)
@classmethod
def from_string(cls, crontab: str) -> crontab:
"""
Create a Crontab from a cron expression string. For example ``crontab.from_string('* * * * *')``.
.. code-block:: text
┌───────────── minute (059)
│ ┌───────────── hour (023)
│ │ ┌───────────── day of the month (131)
│ │ │ ┌───────────── month (112)
│ │ │ │ ┌───────────── day of the week (06) (Sunday to Saturday)
* * * * *
"""
minute, hour, day_of_month, month_of_year, day_of_week = crontab.split(" ")
return cls(minute, hour, day_of_week, day_of_month, month_of_year)
@staticmethod
def _expand_cronspec(
cronspec: Cronspec,
cronspec: int | str | Iterable,
max_: int, min_: int = 0) -> set[Any]:
"""Expand cron specification.
@@ -557,7 +535,7 @@ class crontab(BaseSchedule):
def __repr__(self) -> str:
return CRON_REPR.format(self)
def __reduce__(self) -> tuple[type, tuple[Cronspec, Cronspec, Cronspec, Cronspec, Cronspec], Any]:
def __reduce__(self) -> tuple[type, tuple[str, str, str, str, str], Any]:
return (self.__class__, (self._orig_minute,
self._orig_hour,
self._orig_day_of_week,