
    `f}                       d Z ddlmZ ddlZddlmZmZ ddlmZ ddlm	Z	 ddl
m
Z
mZmZ ddlmZmZmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZmZmZmZm Z m!Z!m"Z" dZ# edd          Z$dZ%dZ&dZ'dZ(dZ)dZ*d0dZ+ G d de,          Z- G d d          Z. G d  d!e.          Z/ G d" d#          Z0 G d$ d%e.          Z1	 	 d1d2d-Z2 G d. d/e.          Z3dS )3z;Schedules define the intervals at which periodic tasks run.    )annotationsN)bisectbisect_left)
namedtuple)Iterable)datetime	timedeltatzinfo)AnyCallableMappingSequence)cached_property)Celery   )current_app)AttributeDict)ffwdhumanize_secondslocalizemaybe_make_awaremaybe_timedelta	remainingtimezoneweekday)ParseExceptionschedulecrontabcrontab_parsermaybe_schedulesolar
schedstateis_duenextzJInvalid crontab pattern.  Valid range is {min}-{max}. '{value}' was found.zoArgument cronspec needs to be of any of the following types: int, str, or an iterable type. {type!r} was given.z}<crontab: {0._orig_minute} {0._orig_hour} {0._orig_day_of_month} {0._orig_month_of_year} {0._orig_day_of_week} (m/h/dM/MY/d)>z?Argument latitude {lat} is invalid, must be between -90 and 90.zBArgument longitude {lon} is invalid, must be between -180 and 180.zAArgument event "{event}" is invalid, must be one of {all_events}.sstrreturnc                    | dn| S )N* )r&   s    B/var/www/html/env/lib/python3.11/site-packages/celery/schedules.py	cronfieldr-   7   s    )33"    c                      e Zd ZdZdS )r   zARaised by :class:`crontab_parser` when the input can't be parsed.N)__name__
__module____qualname____doc__r+   r.   r,   r   r   ;   s        KKKKr.   r   c                      e Zd Zdd dZd!d	Zd"dZd#dZ	 d$d%dZed&d            Z	e	j
        d'd            Z	ed(d            Zed)d            Zd*dZd+dZdS ),BaseScheduleNnowfunCallable | NoneappCelery | Nonec                "    || _         || _        d S N)r6   _app)selfr6   r8   s      r,   __init__zBaseSchedule.__init__A   s    			r.   r(   r   c                8     | j         p| j        j                    S r;   )r6   r8   nowr=   s    r,   r@   zBaseSchedule.nowE   s    ++tx|...r.   last_run_atr	   c                    t                      r;   NotImplementedErrorr=   rB   s     r,   remaining_estimatezBaseSchedule.remaining_estimateH       !###r.   tuple[bool, datetime]c                    t                      r;   rD   rF   s     r,   r$   zBaseSchedule.is_dueK   rH   r.   Tdtnaive_as_utcboolc                0    t          || j        |          S )NrL   )r   tz)r=   rK   rL   s      r,   r   zBaseSchedule.maybe_make_awareN   s    DG,GGGGr.   r   c                6    | j         pt          j                    S r;   )r<   r   _get_current_objectrA   s    r,   r8   zBaseSchedule.appR   s    y=K;===r.   Nonec                    || _         d S r;   )r<   )r=   r8   s     r,   r8   zBaseSchedule.appV   s    			r.   r
   c                    | j         j        S r;   )r8   r   rA   s    r,   rP   zBaseSchedule.tzZ   s    x  r.   c                $    | j         j        j        S r;   )r8   conf
enable_utcrA   s    r,   utc_enabledzBaseSchedule.utc_enabled^   s    x}''r.   c                <    | j         st          j        |          S |S r;   )rY   r   to_local_fallback)r=   rK   s     r,   to_localzBaseSchedule.to_localb   s#     	2-b111	r.   otherr   c                Z    t          |t                    r|j        | j        k    S t          S r;   )
isinstancer5   r6   NotImplementedr=   r]   s     r,   __eq__zBaseSchedule.__eq__g   s)    e\** 	/<4;..r.   )NN)r6   r7   r8   r9   )r(   r   rB   r   r(   r	   rB   r   r(   rI   )T)rK   r   rL   rM   r(   r   )r(   r   )r8   r   r(   rS   )r(   r
   )r(   rM   )rK   r   r(   r   r]   r   r(   rM   )r0   r1   r2   r>   r@   rG   r$   r   propertyr8   setterr   rP   rY   r\   rb   r+   r.   r,   r5   r5   ?   s6           / / / /$ $ $ $$ $ $ $ 6:H H H H H > > > X> 	Z   Z ! ! ! _! ( ( ( _(   
     r.   r5   c                       e Zd ZU dZdZded<   	 	 	 dd  fdZd!dZd"dZd#dZ	d$dZ
d%dZed&d            Zed#d            Z xZS )'r   a  Schedule for periodic task.

    Arguments:
        run_every (float, ~datetime.timedelta): Time interval.
        relative (bool):  If set to True the run time will be rounded to the
            resolution of the interval.
        nowfun (Callable): Function returning the current date and time
            (:class:`~datetime.datetime`).
        app (Celery): Celery app instance.
    FrM   relativeN	run_everyfloat | timedelta | Noner6   r7   r8   r9   r(   rS   c                    t          |          | _        || _        t                                          ||           d S )N)r6   r8   )r   rj   ri   superr>   )r=   rj   ri   r6   r8   	__class__s        r,   r>   zschedule.__init__{   s>     )33 C00000r.   rB   r   r	   c                    t          |                     |          | j        |                     |                                           | j                  S r;   )r   r   rj   r@   ri   rF   s     r,   rG   zschedule.remaining_estimate   sF    !!+..!!$((**--t}
 
 	
r.   rI   c                    |                      |          }|                     |          }t          |                                d          }|dk    rt	          d| j                  S t	          d|          S )aG  Return tuple of ``(is_due, next_time_to_check)``.

        Notes:
            - next time to check is in seconds.

            - ``(True, 20)``, means the task should be run now, and the next
                time to check is in 20 seconds.

            - ``(False, 12.3)``, means the task is not due, but that the
              scheduler should check again in 12.3 seconds.

        The next time to check is used to save energy/CPU cycles,
        it does not need to be accurate but will influence the precision
        of your schedule.  You must also keep in mind
        the value of :setting:`beat_max_loop_interval`,
        that decides the maximum number of seconds the scheduler can
        sleep between re-checking the periodic task intervals.  So if you
        have a task that changes schedule at run-time then your next_run_at
        check will decide how long it will take before a change to the
        schedule takes effect.  The max loop interval takes precedence
        over the next check at value returned.

        .. admonition:: Scheduler max interval variance

            The default max loop interval may vary for different schedulers.
            For the default scheduler the value is 5 minutes, but for example
            the :pypi:`django-celery-beat` database scheduler the value
            is 5 seconds.
        r   Tr#   F)r   rG   maxtotal_secondsr"   seconds)r=   rB   	rem_deltaremaining_ss       r,   r$   zschedule.is_due   sx    < ++K88++K88	)1133Q77!T====[9999r.   r'   c                    d| j          dS )Nz<freq: >)human_secondsrA   s    r,   __repr__zschedule.__repr__   s    .+....r.   r]   r   c                b    t          |t                    r| j        |j        k    S | j        |k    S r;   )r_   r   rj   ra   s     r,   rb   zschedule.__eq__   s0    eX&& 	5>U_44~&&r.   4tuple[type, tuple[timedelta, bool, Callable | None]]c                8    | j         | j        | j        | j        ffS r;   )rn   rj   ri   r6   rA   s    r,   
__reduce__zschedule.__reduce__   s    ~t{KKKr.   int | floatc                P    t          | j                                        d          S )Nr   )rq   rj   rr   rA   s    r,   rs   zschedule.seconds   s     4>//111555r.   c                *    t          | j                  S r;   )r   rs   rA   s    r,   rx   zschedule.human_seconds   s    ---r.   )NFNN)
rj   rk   ri   rM   r6   r7   r8   r9   r(   rS   rc   rd   r(   r'   re   )r(   r{   )r(   r~   )r0   r1   r2   r3   ri   __annotations__r>   rG   r$   ry   rb   r}   rf   rs   rx   __classcell__rn   s   @r,   r   r   m   s        	 	 H=ACG1 1 1 1 1 1 1
 
 
 
#: #: #: #:J/ / / /' ' ' '
L L L L 6 6 6 X6 . . . X. . . . .r.   r   c                  d    e Zd ZdZeZdZdZdZddd
Zd dZ	d!dZ
d"dZd"dZd"dZd#dZd$dZdS )%r   a  Parser for Crontab expressions.

    Any expression of the form 'groups'
    (see BNF grammar below) is accepted and expanded to a set of numbers.
    These numbers represent the units of time that the Crontab needs to
    run on:

    .. code-block:: bnf

        digit   :: '0'..'9'
        dow     :: 'a'..'z'
        number  :: digit+ | dow+
        steps   :: number
        range   :: number ( '-' number ) ?
        numspec :: '*' | range
        expr    :: numspec ( '/' steps ) ?
        groups  :: expr ( ',' expr ) *

    The parser is a general purpose one, useful for parsing hours, minutes and
    day of week expressions.  Example usage:

    .. code-block:: pycon

        >>> minutes = crontab_parser(60).parse('*/15')
        [0, 15, 30, 45]
        >>> hours = crontab_parser(24).parse('*/4')
        [0, 4, 8, 12, 16, 20]
        >>> day_of_week = crontab_parser(7).parse('*')
        [0, 1, 2, 3, 4, 5, 6]

    It can also parse day of month and month of year expressions if initialized
    with a minimum of 1.  Example usage:

    .. code-block:: pycon

        >>> days_of_month = crontab_parser(31, 1).parse('*/3')
        [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31]
        >>> months_of_year = crontab_parser(12, 1).parse('*/2')
        [1, 3, 5, 7, 9, 11]
        >>> months_of_year = crontab_parser(12, 1).parse('2-12/2')
        [2, 4, 6, 8, 10, 12]

    The maximum possible expanded value returned is found by the formula:

        :math:`max_ + min_ - 1`
    z(\w+?)-(\w+)z/(\w+)?z\*<   r   max_intmin_c                T   || _         || _        t          j        | j        | j        z             | j        ft          j        | j                  | j        ft          j        | j        | j        z             | j	        ft          j        d| j        z   dz             | j
        ff| _        d S )N^$)r   r   recompile_range_steps_range_steps_expand_range_star_star_steps_expand_starpats)r=   r   r   s      r,   r>   zcrontab_parser.__init__   s    		Zdk122D4EFZ$$d&89Z
T[01143CDZdj(3.//1BC	>
			r.   specr'   r(   set[int]c                    t                      }|                    d          D ]>}|s|                     d          |t          |                     |                    z  }?|S )N,z
empty part)setsplitr   _parse_part)r=   r   accparts       r,   parsezcrontab_parser.parse  sg    eeJJsOO 	/ 	/D 8)),7773t''--...CC
r.   r   	list[int]c                    | j         D ];\  }}|                    |          }|r ||                                          c S <|                     |f          S r;   )r   matchgroupsr   )r=   r   regexhandlerms        r,   r   zcrontab_parser._parse_part
  si    "i 	+ 	+NE7D!!A +wqxxzz*****+!!4'***r.   toksSequence[str]c                   |                      |d                   }t          |          dk    r|                      |d                   }||k     rPt          t          || j        | j        z                       t          t          | j        |dz                       z   S t          t          ||dz                       S |gS )Nr   r   )_expand_numberlenlistranger   r   )r=   r   frtos       r,   r   zcrontab_parser._expand_range  s      a))t99q==$$T!W--BBwwU2ty49'<==>>U49b1f55667 8b"q&))***tr.   c                    t          |          dk    s|d         s|                     d          |                     |d d                   d d t          |d                            S )N      empty filter)r   r   r   r   r=   r   s     r,   r   zcrontab_parser._range_steps  s^    t99>>a>%%n555!!$rr(++NNc$q'llN;;r.   c                    |r|d         s|                      d          |                                 d d t          |d                            S )Nr   r   )r   r   r   r   s     r,   r   zcrontab_parser._star_steps   sP     	647 	6%%n555  "">>Sa\\>22r.   argsr   c                `    t          t          | j        | j        | j        z                       S r;   )r   r   r   r   )r=   r   s     r,   r   zcrontab_parser._expand_star%  s%    E$)TY%:;;<<<r.   r&   c                   t          |t                    r!|d         dk    r|                     d          	 t          |          }nB# t          $ r5 	 t          |          }n!# t          $ r t	          d|d          w xY wY nw xY w| j        | j        z   dz
  }||k    rt	          d| d| d          || j        k     rt	          d	| d
| j         d          |S )Nr   -znegative numbers not supportedzInvalid weekday literal .r   zInvalid end range: z > zInvalid beginning range: z < )	r_   r'   r   r   
ValueErrorr   KeyErrorr   r   )r=   r&   imax_vals       r,   r   zcrontab_parser._expand_number(  s@   a 	H!A$#++%%&FGGG	DAAA 	D 	D 	DDAJJ D D D !BA!B!B!BCCCD 	D )di'!+w;;6a66G6668 8 8ty==>A>>$)>>>@ @ @ s)   A 
BA#"B#BBBN)r   r   )r   r   r   r   )r   r'   r(   r   )r   r'   r(   r   )r   r   r(   r   )r   r   r(   r   )r&   r'   r(   r   )r0   r1   r2   r3   r   r   r   r   r>   r   r   r   r   r   r   r   r+   r.   r,   r   r      s        - -^ $NFFE
 
 
 
 
   + + + +   < < < <
3 3 3 3
= = = =     r.   r   c                       e Zd ZdZ	 	 d/d0 fdZe	 d1d2d            Zd3dZd4dZd5dZ	d6 fd!Z
d"efd7d'Zefd8d)Zd9d+Zd: fd.Z xZS );r   a  Crontab schedule.

    A Crontab can be used as the ``run_every`` value of a
    periodic task entry to add :manpage:`crontab(5)`-like scheduling.

    Like a :manpage:`cron(5)`-job, you can specify units of time of when
    you'd like the task to execute.  It's a reasonably complete
    implementation of :command:`cron`'s features, so it should provide a fair
    degree of scheduling needs.

    You can specify a minute, an hour, a day of the week, a day of the
    month, and/or a month in the year in any of the following formats:

    .. attribute:: minute

        - A (list of) integers from 0-59 that represent the minutes of
          an hour of when execution should occur; or
        - A string representing a Crontab pattern.  This may get pretty
          advanced, like ``minute='*/15'`` (for every quarter) or
          ``minute='1,13,30-45,50-59/2'``.

    .. attribute:: hour

        - A (list of) integers from 0-23 that represent the hours of
          a day of when execution should occur; or
        - A string representing a Crontab pattern.  This may get pretty
          advanced, like ``hour='*/3'`` (for every three hours) or
          ``hour='0,8-17/2'`` (at midnight, and every two hours during
          office hours).

    .. attribute:: day_of_week

        - A (list of) integers from 0-6, where Sunday = 0 and Saturday =
          6, that represent the days of a week that execution should
          occur.
        - A string representing a Crontab pattern.  This may get pretty
          advanced, like ``day_of_week='mon-fri'`` (for weekdays only).
          (Beware that ``day_of_week='*/2'`` does not literally mean
          'every two days', but 'every day that is divisible by two'!)

    .. attribute:: day_of_month

        - A (list of) integers from 1-31 that represents the days of the
          month that execution should occur.
        - A string representing a Crontab pattern.  This may get pretty
          advanced, such as ``day_of_month='2-30/2'`` (for every even
          numbered day) or ``day_of_month='1-7,15-21'`` (for the first and
          third weeks of the month).

    .. attribute:: month_of_year

        - A (list of) integers from 1-12 that represents the months of
          the year during which execution can occur.
        - A string representing a Crontab pattern.  This may get pretty
          advanced, such as ``month_of_year='*/3'`` (for the first month
          of every quarter) or ``month_of_year='2-12/2'`` (for every even
          numbered month).

    .. attribute:: nowfun

        Function returning the current date and time
        (:class:`~datetime.datetime`).

    .. attribute:: app

        The Celery app instance.

    It's important to realize that any day on which execution should
    occur must be represented by entries in all three of the day and
    month attributes.  For example, if ``day_of_week`` is 0 and
    ``day_of_month`` is every seventh day, only months that begin
    on Sunday and are also in the ``month_of_year`` attribute will have
    execution events.  Or, ``day_of_week`` is 1 and ``day_of_month``
    is '1-7,15-21' means every first and third Monday of every month
    present in ``month_of_year``.
    r*   minuter'   hourday_of_weekday_of_monthmonth_of_yearkwargsr   r(   rS   c                "   t          |          | _        t          |          | _        t          |          | _        t          |          | _        t          |          | _        || _        |                     |d          | _        |                     |d          | _	        |                     |d          | _
        |                     |dd          | _        |                     |dd          | _         t                      j        di | d S )N   r         r      r+   )r-   _orig_minute
_orig_hour_orig_day_of_week_orig_day_of_month_orig_month_of_year_orig_kwargs_expand_cronspecr   r   r   r   r   rm   r>   )r=   r   r   r   r   r   r   rn   s          r,   r>   zcrontab.__init__  s    %f--#D//!*;!7!7"+L"9"9#,]#;#; "))$33	++FB7700a@@ 11,AFF!22="aHH""6"""""r.   r   cronspecint | str | Iterabler   r   r   set[Any]c                   t          | t                    r| h}nt          | t                    r$t          ||                              |           }nrt          | t
                    r| }nZt          | t                    rt          |           }n5t          t          	                    t          |                               |D ]A}|||z   k    s||k     r0t          t          	                    ||dz
  |z   |                    B|S )a  Expand cron specification.

        Takes the given cronspec argument in one of the forms:

        .. code-block:: text

            int         (like 7)
            str         (like '3-5,*/15', '*', or 'monday')
            set         (like {0,15,30,45}
            list        (like [8-17])

        And convert it to an (expanded) set representing all time unit
        values on which the Crontab triggers.  Only in case of the base
        type being :class:`str`, parsing occurs.  (It's fast and
        happens only once for each Crontab instance, so there's no
        significant performance overhead involved.)

        For the other base types, merely Python type conversions happen.

        The argument ``max_`` is needed to determine the expansion of
        ``*`` and ranges.  The argument ``min_`` is needed to determine
        the expansion of ``*`` and ranges for 1-based cronspecs, such as
        day of month or month of year.  The default is sufficient for minute,
        hour, and day of week.
        )typer   )minrq   value)r_   r   r'   r   r   r   r   	TypeErrorCRON_INVALID_TYPEformatr   r   CRON_PATTERN_INVALID)r   r   r   resultnumbers        r,   r   zcrontab._expand_cronspec  s&   : h$$ 		KZFF#&& 	K#D$//55h??FF#&& 	KFF(++ 	K]]FF-44$x..4IIJJJ  	B 	BF$$ !5!<!<$(T/ "= "A "A B B B )6 r.   rB   r   	next_hournext_minuter   c           	        	
 t          j                  t           j                  t           j                  
ddd fd		d	
fd}j         j        v r5t          j                  _        t          
j                  _
        n@d_        t          
j                  _
        j
        t          
          k    rd_
         |             	 t          j        
j
                 j                           }|                                dz   j        v rnxj        dz  c_         |             gt          j        
j
                 j                 dd          S )aZ  Find next delta.

        Takes a :class:`~datetime.datetime` of last run, next minute and hour,
        and returns a :class:`~celery.utils.time.ffwd` for the next
        scheduled day and time.

        Only called when ``day_of_month`` and/or ``month_of_year``
        cronspec is specified to further limit scheduled task execution.
        )yearr   r   monthdayr(   rM   c                P    	 t          | ||           n# t          $ r Y dS w xY wdS )Nr   r   r   TF)r   r   r   s      r,   day_out_of_rangez0crontab._delta_to_next.<locals>.day_out_of_range  sF    d%S99999   tt5s    
##c           	     \                         t          | ||          d          k     S )NFrO   )r   r   )r   r   r   rB   r   r   r=   s      r,   is_before_last_runz2crontab._delta_to_next.<locals>.is_before_last_run  s>    ((uc9kBB" ) $ $&12 2r.   rS   c                    t          d          D ]} j        t                    k    pO j        j                 j                           p' j        j                 j                           }|rGd_        xj        dz  c_        j        t                    k    rd_        xj        dz  c_         d S t          d          )Ni  r   r   z:unable to rollover, time specification is probably invalid)r   domr   r   moyRuntimeError)_flagdatedatar   days_of_monthr   months_of_years     r,   	roll_overz)crontab._delta_to_next.<locals>.roll_over  s   4[[ M M M(:(:: J(()7)E)6x|)DF FJ ,+HM,:8<,H,9(,,GI I	   #$HLLLA%LL|s>':':::'( *EE # $L M M Mr.   r   r   r   r   )r   r   r   r   r   secondmicrosecond)r   r   r   r   r   r   r(   rM   )r(   rS   )r   r   sortedr   r   r   r   r   r   r   r   r   r   
isoweekdayr   r   )r=   rB   r   r   r   thr   r   r   r   r   s   ````  @@@@@r,   _delta_to_nextzcrontab._delta_to_next  s    !k&6777t011 233	 	 	 		2 	2 	2 	2 	2 	2 	2 	2 	2
	M 	M 	M 	M 	M 	M 	M 	M 	M 	M.  222!-AAHL&~{7HIIHLLHL!.+2CDDHL|s>2222 		x} .x| <+HL9; ; ;B }}"d&666LLALLIKKK	 (6%hl3"& !# # # 	#r.   c                6    t                               |           S r;   )	CRON_REPRr   rA   s    r,   ry   zcrontab.__repr__  s    %%%r.   0tuple[type, tuple[str, str, str, str, str], Any]c                \    | j         | j        | j        | j        | j        | j        f| j        fS r;   )rn   r   r   r   r   r   r   rA   s    r,   r}   zcrontab.__reduce__  s=    !2!%!%!7!%!8!%!9	!; =A<M	O 	Or.   stateMapping[str, Any]c                :     t                      j        di | d S )Nr+   )rm   r>   )r=   r   rn   s     r,   __setstate__zcrontab.__setstate__!  s(     	!!5!!!!!r.   NrP   tzinfo | Noner   tuple[datetime, Any, datetime]c                J   |                                |                      |                                           }                                dz  j        | j        v oj        | j        v o| j        v }|oZj        |j        k    oJj        |j        k    o:j        |j        k    o*j	        | j	        v oj
        t          | j
                  k     }|r/t          fd| j
        D                       } ||dd          }nt          | j
                  }|oj	        t          | j	                  k     }	|	r0t          fd| j	        D                       }
 ||
|dd          }nt          | j	                  }
| j        dk    o
| j        dk    }|rIt          fd| j        D             p| j                  }|k    } ||rd	pd|d	z
  dz  |
|dd
          }n|                     |
|          }|                               ||                     |          fS )Nr   c              3  2   K   | ]}|j         k    |V  d S r;   )r   ).0r   rB   s     r,   	<genexpr>z*crontab.remaining_delta.<locals>.<genexpr>=  s<       > >!'+*<!<!< %!<!<!<!<> >r.   r   )r   r   r   c              3  2   K   | ]}|j         k    |V  d S r;   )r   )r  r   rB   s     r,   r  z*crontab.remaining_delta.<locals>.<genexpr>F  s<        <  <#'+*:#:#: !%#:#:#:#: <  <r.   )r   r   r   r   r*   c                     g | ]
}|k    |S r+   r+   )r  r   dow_nums     r,   
<listcomp>z+crontab.remaining_delta.<locals>.<listcomp>O  s)     $6 $6 $6C'*W}} %('4}}r.   r   )weeksr   r   r   r   r   )r   r@   r   r   r   r   r   r   r   r   r   rq   r   r   r   r   r\   )r=   rB   rP   r   r@   execute_this_dateexecute_this_hourr   deltaexecute_todayr   all_dom_moynext_dayadd_weekr  s    `            @r,   remaining_deltazcrontab.remaining_delta&  s    ++K88##DHHJJ//((**Q. !33 (Ot00(t'' 	  2Osw&2*2 (2 	)	2
 T[!1!11 	  !	H > > > >4; > > > > >KDA1EEEEEdk**K. ?(-DI>   H  <  <  <  <  <  <  < < <	)K$%16 6 6  	NN	#6#=  ?#73>  H" $6 $6 $6 $643C $6 $6 $6 $J9=9I K  KH'72H D&n11!)A 2&* $%  EE !//09;H HE}}[))5$--2D2DDDr.   r	   c                >    t          |                     ||           S )zEstimate of next run time.

        Returns when the periodic task should run next as a
        :class:`~datetime.timedelta`.
        )r   )r   r  )r=   rB   r   s      r,   rG   zcrontab.remaining_estimate`  s"     $..{.FFGGr.   rI   c                    |                      |          }|                                }t          |d          }|dk    }| j        j        j        }d}|^|}|}	|dk     rI|t          |          z   }|                      |          }|                                }|dk     r|}	|dk     I|	 |k    }|rd}|s|rI|                      |                                           }t          |                                d          }t          ||          S )a  Return tuple of ``(is_due, next_time_to_run)``.

        If :setting:`beat_cron_starting_deadline`  has been specified, the
        scheduler will make sure that the `last_run_at` time is within the
        deadline. This prevents tasks that could have been run according to
        the crontab, but didn't, from running again unexpectedly.

        Note:
            Next time to run is in seconds.

        SeeAlso:
            :meth:`celery.schedules.schedule.is_due` for more information.
        r   F)	rG   rr   rq   r8   rW   beat_cron_starting_deadlineabsr@   r"   )
r=   rB   rt   rem_secsremduedeadline_secshas_passed_deadlinelast_date_checkedlast_feasible_rem_secss
             r,   r$   zcrontab.is_duek  s4    ++K88	**,,(AQhA#$ !,%-"Q,,$5I$F! 334EFF	$2244a<<-5* Q,, $:"9M"I"   	4% 	4//

;;Ii--//33C#s###r.   r]   rM   c                   t          |t                    rq|j        | j        k    o`|j        | j        k    oP|j        | j        k    o@|j        | j        k    o0|j        | j        k    o t                                          |          S t          S r;   )
r_   r   r   r   r   r   r   rm   rb   r`   )r=   r]   rn   s     r,   rb   zcrontab.__eq__  s    eW%% 	#t'99 &"d&77&!T%55& 
di'& +	&
 u%% r.   )r*   r*   r*   r*   r*   )r   r'   r   r'   r   r'   r   r'   r   r'   r   r   r(   rS   )r   )r   r   r   r   r   r   r(   r   )rB   r   r   r   r   r   r(   r   r   )r(   r   )r   r   r(   rS   )rB   r   rP   r  r   r   r(   r  )rB   r   r   r   r(   r	   rd   re   )r0   r1   r2   r3   r>   staticmethodr   r   ry   r}   r  r   r  rG   r$   rb   r   r   s   @r,   r   r   >  sf       K KZ OR?B# # # # # # #  $%, , , , \,\K# K# K# K#Z& & & &O O O O" " " " " "
 JN%)8E 8E 8E 8E 8Ev 7;	H 	H 	H 	H 	H/$ /$ /$ /$b
 
 
 
 
 
 
 
 
 
r.   r   F&int | float | timedelta | BaseScheduleri   rM   r8   r9    float | timedelta | BaseSchedulec                    | Zt          | t          t          f          rt          |           } t          | t                    rt	          | ||          S || _        | S )z;Return schedule from number, timedelta, or actual schedule.N)rs   )r8   )r_   floatr   r	   r   r8   )r&   ri   r8   s      r,   r    r      sb     	}a%&& 	%!$$$Aa## 	AxS1111AEHr.   c            
           e Zd ZdZh dZdddddddddd		Zd
d
d
d
dddddd		Zdddddddddd		Zd% fdZd&dZ	d'dZ
d(dZd)d!Zd*d$Z xZS )+r!   aS  Solar event.

    A solar event can be used as the ``run_every`` value of a
    periodic task entry to schedule based on certain solar events.

    Notes:

        Available event values are:

            - ``dawn_astronomical``
            - ``dawn_nautical``
            - ``dawn_civil``
            - ``sunrise``
            - ``solar_noon``
            - ``sunset``
            - ``dusk_civil``
            - ``dusk_nautical``
            - ``dusk_astronomical``

    Arguments:
        event (str): Solar event that triggers this task.
            See note for available values.
        lat (float): The latitude of the observer.
        lon (float): The longitude of the observer.
        nowfun (Callable): Function returning the current date and time
            as a class:`~datetime.datetime`.
        app (Celery): Celery app instance.
    >	   sunsetsunrise
dawn_civil
dusk_civil
solar_noondawn_nauticaldusk_nauticaldawn_astronomicaldusk_astronomicalz-18z-12z-6z-0:34018)	r/  r-  r*  r)  r,  r(  r+  r.  r0  next_risingnext_transitnext_settingTFeventr'   latr~   lonr   r   r(   rS   c           
     "   t          d          | _        || _        || _        || _         t                      j        di | || j        vrNt          t          
                    |d                    t          | j                                                |dk     s|dk    r(t          t          
                    |                    |dk     s|dk    r(t          t          
                    |	                    | j                                        }t!          |          |_        t!          |          |_        d
|_        | j        |         |_        d
|_        || _        | j        |         | _        | j        |         | _        d S )Nephemz, )r6  
all_eventsiZ   )r7  iL   )r8  r   r+   )
__import__r:  r6  r7  r8  rm   r>   _all_eventsr   SOLAR_INVALID_EVENTr   joinr   SOLAR_INVALID_LATITUDESOLAR_INVALID_LONGITUDEObserverr'   elev	_horizonshorizonpressurecal_methodsmethod_use_center_l
use_center)r=   r6  r7  r8  r   rI  rn   s         r,   r>   zsolar.__init__  sm   ((

""6"""(((077		&9I2J2J(K(K 8      99b3::s:CCDDD::s4;;;DDEEEj!!##c((c((nU+mE*,U3r.   1tuple[type, tuple[str, int | float, int | float]]c                8    | j         | j        | j        | j        ffS r;   )rn   r6  r7  r8  rA   s    r,   r}   zsolar.__reduce__  s    ~
DHdh???r.   c                N    d                     | j        | j        | j                  S )Nz)<solar: {} at latitude {}, longitude: {}>)r   r6  r7  r8  rA   s    r,   ry   zsolar.__repr__!  s'    :AAJ$(
 
 	
r.   rB   r   r	   c                   |                      |          }t          |t          j                  }|| j        _        	 | j        rC t          | j        | j                  | j	        
                                || j                  }n< t          | j        | j                  | j	        
                                |          }nW# | j	        j        $ rE | j                            | j	        
                                          t          d          z   }Y nw xY w|                      |                                          }|                      |                                           }||z
  }|S )a2  Return estimate of next time to run.

        Returns:
            ~datetime.timedelta: when the periodic task should
                run next, or if it shouldn't run today (e.g., the sun does
                not rise today), returns the time when the next check
                should take place.
        )startrM  )rR  r   )minutes)r   r   r   utcrI  daterM  getattrrK  r:  SunCircumpolarErrornext_antitransitr	   r   r@   )r=   rB   last_run_at_utcnext_utcr%   r@   r  s          r,   rG   zsolar.remaining_estimate&  s]    ++K88";=='	 9748T[99JNN$$)do  
 :748T[99JNN$$O   z* 	 	 	 ))$*..*:*:;;!$$$% HH	 $$X%6%6%8%899##DHHJJ//s
s   BC ADDrI   c                2   |                      |          }t          |                                d          }|dk    }|rI|                      |                                           }t          |                                d          }t	          ||          S )zReturn tuple of ``(is_due, next_time_to_run)``.

        Note:
            next time to run is in seconds.

        See Also:
            :meth:`celery.schedules.schedule.is_due` for more information.
        r   )rG   rq   rr   r@   r"   )r=   rB   rt   r  r  s        r,   r$   zsolar.is_dueI  s     ++K88	)))++Q//Qh 	4//

;;Ii--//33C#s###r.   r]   rM   c                    t          |t                    r0|j        | j        k    o|j        | j        k    o|j        | j        k    S t
          S r;   )r_   r!   r6  r7  r8  r`   ra   s     r,   rb   zsolar.__eq__Z  sO    eU## 	tz) &	TX%&	TX%
 r.   )
r6  r'   r7  r~   r8  r~   r   r   r(   rS   )r(   rN  r   rc   rd   re   )r0   r1   r2   r3   r?  rF  rJ  rL  r>   r}   ry   rG   r$   rb   r   r   s   @r,   r!   r!     s<        :
 
 
K #!
 
I +&# $ $'+
 
H "!
 
M4 4 4 4 4 48@ @ @ @
 
 
 

! ! ! !F$ $ $ $"       r.   r!   )r&   r'   r(   r'   )FN)r&   r#  ri   rM   r8   r9   r(   r$  )4r3   
__future__r   r   r   r   collectionsr   collections.abcr   r   r	   r
   typingr   r   r   r   kombu.utils.objectsr   celeryr    r   utils.collectionsr   
utils.timer   r   r   r   r   r   r   r   __all__r"   r   r   r   rB  rC  r@  r-   	Exceptionr   r5   r   r   r   r    r!   r+   r.   r,   <module>ri     s   A A " " " " " " 				 & & & & & & & & " " " " " " $ $ $ $ $ $ 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 / / / / / /             , , , , , ," " " " " " " " " " " " " " " " " " " "
 Z&899
 
 
	
   
# # # #L L L L LY L L L+ + + + + + + +\R. R. R. R. R.| R. R. R.jy y y y y y y yxh h h h hl h h hX EJ!    j j j j jL j j j j jr.   