
    Qi+                         d dl mZmZ d dlm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mZmZmZ ej&                  Z G d d      Zy	)
    )IterableMapping)timezone)isclassismethod)uuid4)BaseTrigger)check_callable_argsconvert_to_datetimedatetime_reprget_callable_name
obj_to_ref
ref_to_objc                        e Zd ZdZdZd fd	Zd Zd Zd Zd Z	d Z
ed	        Zd
 Zd Zd Zd Zd Zd Zd Z xZS )Joba  
    Contains the options given when scheduling callables and its current schedule and other state.
    This class should never be instantiated by the user.

    :var str id: the unique identifier of this job
    :var str name: the description of this job
    :var func: the callable to execute
    :var tuple|list args: positional arguments to the callable
    :var dict kwargs: keyword arguments to the callable
    :var bool coalesce: whether to only run the job once when several run times are due
    :var trigger: the trigger object that controls the schedule of this job
    :var str executor: the name of the executor that will run this job
    :var int misfire_grace_time: the time (in seconds) how much this job's execution is allowed to
        be late (``None`` means "allow the job to run no matter how late it is")
    :var int max_instances: the maximum number of concurrently executing instances allowed for this
        job
    :var datetime.datetime next_run_time: the next scheduled run time of this job

    .. note::
        The ``misfire_grace_time`` has some non-obvious effects on job execution. See the
        :ref:`missed-job-executions` section in the documentation for an in-depth explanation.
    )__weakref___jobstore_alias
_schedulerargscoalesceexecutorfuncfunc_refidkwargsmax_instancesmisfire_grace_timenamenext_run_timetriggerc                     t         |           || _        d | _         | j                  dd|xs t               j                  i| y )Nr    )super__init__r   r   _modifyr   hex)self	schedulerr   r   	__class__s       :/app/.venv/lib/python3.12/site-packages/apscheduler/job.pyr$   zJob.__init__=   s>    ##4)egkk4V4    c                 j     | j                   j                  | j                  | j                  fi | | S )a-  
        Makes the given changes to this job and saves it in the associated job store.

        Accepted keyword arguments are the same as the variables on this class.

        .. seealso:: :meth:`~apscheduler.schedulers.base.BaseScheduler.modify_job`

        :return Job: this job instance

        )r   
modify_jobr   r   )r'   changess     r*   modifyz
Job.modifyC   s.     	#""477D,@,@LGLr+   c                 l     | j                   j                  | j                  | j                  |fi | | S )z
        Shortcut for switching the trigger on this job.

        .. seealso:: :meth:`~apscheduler.schedulers.base.BaseScheduler.reschedule_job`

        :return Job: this job instance

        )r   reschedule_jobr   r   )r'   r    trigger_argss      r*   
reschedulezJob.rescheduleQ   s8     	'&&GGT))7	
6B	
 r+   c                 f    | j                   j                  | j                  | j                         | S )z
        Temporarily suspend the execution of this job.

        .. seealso:: :meth:`~apscheduler.schedulers.base.BaseScheduler.pause_job`

        :return Job: this job instance

        )r   	pause_jobr   r   r'   s    r*   pausez	Job.pause_   s'     	!!$''4+?+?@r+   c                 f    | j                   j                  | j                  | j                         | S )z
        Resume the schedule of this job if previously paused.

        .. seealso:: :meth:`~apscheduler.schedulers.base.BaseScheduler.resume_job`

        :return Job: this job instance

        )r   
resume_jobr   r   r6   s    r*   resumez
Job.resumek   s'     	""477D,@,@Ar+   c                 d    | j                   j                  | j                  | j                         y)z
        Unschedules this job and removes it from its associated job store.

        .. seealso:: :meth:`~apscheduler.schedulers.base.BaseScheduler.remove_job`

        N)r   
remove_jobr   r   r6   s    r*   removez
Job.removew   s"     	""477D,@,@Ar+   c                     | j                   du S )z{
        Returns ``True`` if the referenced job is still waiting to be added to its designated job
        store.

        N)r   r6   s    r*   pendingzJob.pending   s     ##t++r+   c                 2   g }| j                   }|r|j                  t              |j                  t              k  r[|j                  |       | j                  j                  ||      }|r,|j                  t              |j                  t              k  r[|S )z
        Computes the scheduled run times between ``next_run_time`` and ``now`` (inclusive).

        :type now: datetime.datetime
        :rtype: list[datetime.datetime]

        )r   
astimezoneUTCappendr    get_next_fire_time)r'   now	run_timesr   s       r*   _get_run_timeszJob._get_run_times   s     	** 8 8 =PSAT T]+ LL;;M3OM  8 8 =PSAT T r+   c                 "   i }d|v rH|j                  d      }t        |t              st        d      t	        | d      rt        d      ||d<   d|v s	d|v sd|v rGd|v r|j                  d      n| j                  }d|v r|j                  d      n| j                  }d|v r|j                  d      n| j                  }t        |t              r|}t        |      }n#t        |      r	 t        |      }nt        d      t	        | d	      s |j                  d	d      t        |      |d	<   t        |t              st        |t              st        d
      t        |t              st        |t              st        d      t!        |||       ||d<   ||d<   ||d<   ||d<   d	|v r3|j                  d	      }|rt        |t              st        d      ||d	<   d|v r8|j                  d      }| t        |t"              r|dk  rt        d      ||d<   d|v rt%        |j                  d            }||d<   d|v r6|j                  d      }t        |t"              r|dk  rt        d      ||d<   d|v rI|j                  d      }t        |t&              s#t        d|j(                  j*                   d      ||d<   d|v r1|j                  d      }t        |t              st        d      ||d<   d|v r5|j                  d      }t-        || j.                  j0                  d      |d<   |r)t3        dj5                  dj7                  |                  |j9                         D ]  \  }	}t;        | |	|        y# t
        $ r d}Y w xY w)z|
        Validates the changes to the Job and makes the modifications if and only if all of them
        validate.

        r   zid must be a nonempty stringzThe job ID may not be changedr   r   r   Nz5func must be a callable or a textual reference to oner   z"args must be a non-string iterablez!kwargs must be a dict-like objectr   zname must be a nonempty stringr   r   z<misfire_grace_time must be either None or a positive integerr   r   z(max_instances must be a positive integerr    z!Expected a trigger instance, got z insteadr   zexecutor must be a stringr   z6The following are not modifiable attributes of Job: {}, )pop
isinstancestr	TypeErrorhasattr
ValueErrorr   r   r   r   callabler   getr   r   r   r
   intboolr	   r)   __name__r   r   r   AttributeErrorformatjoinitemssetattr)
r'   r.   approvedvaluer   r   r   r   r    keys
             r*   r%   zJob._modify   s    7?KK%EeS) >??tT" !@AA"HTNW' 1X5H*0G*;7;;v&D*0G*;7;;v&D.6'.AW[[*t{{F$$!$'$$)$/H
   WXX4(W[[-F-N"3D"9$$JtX,F DEE&#&j.I CDDdF3#HV#+HZ #HV!'HXWKK'E
5# 6 @AA$HV7*KK 45E *UC*@EQJR  .3H)* Z01E#(HZ g%KK0EeS)UaZ JKK(-H_%kk),Gg{378I8I8R8R7SS[\  #*HY KK
+EeS) ;<<#(HZ g%KK0E(;t//)H_%  HOOIIg&  #..*JCD#u% +S " $#H$s   )M? ?NNc                    | j                   st        d| j                  d      | j                  }t        |      rQt	        |j
                        s<t        |      | j                   k(  r$|j
                  ft        | j                        z   }n| j                  }d| j                  | j                   | j                  | j                  || j                  | j                  | j                  | j                  | j                   | j"                  dS )NzCThis Job cannot be serialized since the reference to its callable (z^) could not be determined. Consider giving a textual reference (module:function name) instead.   )versionr   r   r    r   r   r   r   r   r   r   r   )r   rO   r   r   r   __self__r   tupler   r   r    r   r   r   r   r   r   r   )r'   r   r   s      r*   __getstate__zJob.__getstate__  s    }}UVZV_V_Ub c   yyTNDMM*4 DMM1MM#eDII&66D99D ''MM||kkII"&"9"9!//!//
 	
r+   c                 b   |j                  dd      dkD  rt        d|d    d      |d   | _        |d   | _        t	        | j                        | _        |d   | _        |d   | _        |d	   | _        |d
   | _	        |d   | _
        |d   | _        |d   | _        |d   | _        |d   | _        y )Nr_   r^   zJob has version z#, but only version 1 can be handledr   r   r    r   r   r   r   r   r   r   r   )rQ   rO   r   r   r   r   r    r   r   r   r   r   r   r   r   )r'   states     r*   __setstate__zJob.__setstate__(  s    99Y"Q&"5#3"44WX  +ft}}-	Y'j)&M	Ho&M	"'(<"=j)"?3"?3r+   c                 `    t        |t              r| j                  |j                  k(  S t        S N)rK   r   r   NotImplemented)r'   others     r*   __eq__z
Job.__eq__;  s%    eS!77ehh&&r+   c                 <    d| j                    d| j                   dS )Nz	<Job (id=z name=z)>)r   r   r6   s    r*   __repr__zJob.__repr__@  s    477)6$))B77r+   c                     t        | d      r'| j                  rdt        | j                        z   nd}nd}| j                   d| j                   d| dS )Nr   znext run at: pausedr?   z (trigger: rI   ))rN   r   r   r   r    )r'   statuss     r*   __str__zJob.__str__C  s\    4) %%  -0B0B"CC  F))K~RxqAAr+   rg   )rT   
__module____qualname____doc__	__slots__r$   r/   r3   r7   r:   r=   propertyr?   rG   r%   rb   re   rj   rl   rq   __classcell__)r)   s   @r*   r   r      si    .I$5

B , , e&N"
H4&
8
Br+   r   N)collections.abcr   r   datetimer   inspectr   r   uuidr   apscheduler.triggers.baser	   apscheduler.utilr
   r   r   r   r   r   utcrB   r   r"   r+   r*   <module>r      s7    -  %  1  llzB zBr+   