
    df+                         d dl mZmZ d dlmZ d dlZd dlmZ d dlm	Z	m
Z
mZmZmZmZmZ 	 d dlmZmZ  G d de      Zy# e$ r d dlmZmZ Y w xY w)	    )ismethodisclass)uuid4N)BaseTrigger)
ref_to_obj
obj_to_refdatetime_reprrepr_escapeget_callable_namecheck_callable_argsconvert_to_datetime)IterableMappingc                        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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.
    )
_scheduler_jobstore_aliasidtriggerexecutorfuncfunc_refargskwargsnamemisfire_grace_timecoalescemax_instancesnext_run_time__weakref__c                     t         t        |           || _        d | _         | j
                  dd|xs t               j                  i| y )Nr    )superr   __init__r   r   _modifyr   hex)self	schedulerr   r   	__class__s       H/home/api-vastappli/venv/lib/python3.12/site-packages/apscheduler/job.pyr$   zJob.__init__-   s@    c4!###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.modify3   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.rescheduleA   s1     	'&&tww0D0Dg^Q]^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.pauseM   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.resumeY   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.removee   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.pendingn   s     ##t++r+   c                     g }| j                   }|r:||k  r5|j                  |       | j                  j                  ||      }|r||k  r5|S )z
        Computes the scheduled run times between ``next_run_time`` and ``now`` (inclusive).

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

        )r   appendr   get_next_fire_time)r'   now	run_timesr   s       r*   _get_run_timeszJob._get_run_times{   sV     	** 4]+ LL;;M3OM  4 r+   c                    i }d|v rR|j                  d      }t        |t        j                        st	        d      t        | d      rt        d      ||d<   d|v s	d|v sd|v red|v r|j                  d      n| j                  }d|v r|j                  d      n| j                  }d|v r|j                  d      n| j                  }t        |t        j                        r|}t        |      }n#t        |      r	 t        |      }nt	        d      t        | d	      s |j                  d	d      t        |      |d	<   t        |t        j                        st        |t              st	        d
      t        |t        j                        st        |t               st	        d      t#        |||       ||d<   ||d<   ||d<   ||d<   d	|v r=|j                  d	      }|rt        |t        j                        st	        d      ||d	<   d|v rB|j                  d      }|*t        |t        j$                        r|dk  rt	        d      ||d<   d|v rt'        |j                  d            }||d<   d|v r@|j                  d      }t        |t        j$                        r|dk  rt	        d      ||d<   d|v rH|j                  d      }t        |t(              s"t	        d|j*                  j,                  z        ||d<   d|v r;|j                  d      }t        |t        j                        st	        d      ||d<   d|v r5|j                  d      }t/        || j0                  j2                  d      |d<   |rt5        ddj7                  |      z        t        j8                  |      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 %s insteadr   zexecutor must be a stringr   z6The following are not modifiable attributes of Job: %s, )pop
isinstancesixstring_types	TypeErrorhasattr
ValueErrorr   r   r   r   callabler   getr   r   r   r   integer_typesboolr   r)   __name__r   r   timezoneAttributeErrorjoin	iteritemssetattr)
r'   r.   approvedvaluer   r   r   r   r   keys
             r*   r%   zJob._modify   s    7?KK%EeS%5%56 >??tT" !@AA"HTNW' 1X5H*0G*;7;;v&D*0G*;7;;v&D.6'.AW[[*t{{F$ 0 01!$'$$)$/H
   WXX4(W[[-F-N"3D"9$ 0 01D(9S DEE&#"2"23:fg;V CDDdF3#HV#+HZ #HV!'HXWKK'E
5#2B2B C @AA$HV7*KK 45E *UC<M<M*NRW[\R\ ^__-2H)* Z01E#(HZ g%KK0EeS%6%675A: JKK(-H_%kk),Gg{3 M ' 1 1 : :!; < < #*HY KK
+EeS%5%56 ;<<#(HZ g%KK0E(;E4??C[C[<K)MH_%  !Y!%7!3"4 5 5 --1 	&JCD#u%	&E " $#H$s   =O OO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   rN   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    }} #ii*+ + yyD>'$--"8Z=MQUQ^Q^=^MM#eDII&66D99D ''MM||kkII"&"9"9!//!//
 	
r+   c                 `   |j                  dd      dkD  rt        d|d   z        |d   | _        |d   | _        t	        | j                        | _        |d   | _        |d   | _        |d   | _        |d	   | _	        |d
   | _
        |d   | _        |d   | _        |d   | _        |d   | _        y )Nr^   r]   z5Job has version %s, but only version 1 can be handledr   r   r   r   r   r   r   r   r   r   r   )rP   rN   r   r   r   r   r   r   r   r   r   r   r   r   r   )r'   states     r*   __setstate__zJob.__setstate__
  s    99Y"Q&T"9-. / / +ft}}-	Y'j)&M	Ho&M	"'(<"=j)"?3"?3r+   c                 `    t        |t              r| j                  |j                  k(  S t        S N)rI   r   r   NotImplemented)r'   others     r*   __eq__z
Job.__eq__  s%    eS!77ehh&&r+   c                 `    dt        | j                        dt        | j                        dS )Nz	<Job (id=z name=z)>)r
   r   r   r6   s    r*   __repr__zJob.__repr__!  s    *5dgg*>DII@VWWr+   c                 4    t        | j                               S rf   )r
   __unicode__r6   s    r*   __str__zJob.__str__$  s    4++-..r+   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: rG   ))rM   r   r	   r   r   )r'   statuss     r*   rm   zJob.__unicode__'  sN    4)(( &d6H6H(II.6  F*.))T\\6JJr+   rf   )rS   
__module____qualname____doc__	__slots__r$   r/   r3   r7   r:   r=   propertyr?   rE   r%   ra   rd   ri   rk   rn   rm   __classcell__)r)   s   @r*   r   r      sn    .1I5


B , , ^&@
>4$
X/Kr+   r   )inspectr   r   uuidr   rJ   apscheduler.triggers.baser   apscheduler.utilr   r   r	   r
   r   r   r   collections.abcr   r   ImportErrorcollectionsobjectr   r"   r+   r*   <module>r      sO    %  
 1  .1
]K& ]K	  .--.s   A   AA