o
    th                     @   sj   d dl mZmZ d dlZd dlZG dd deZG dd deZG dd deZ	G d	d
 d
e
eZdS )    )ABCMetaabstractmethodNc                           e Zd ZdZ fddZ  ZS )JobLookupErrorzBRaised when the job store cannot find a job for update or removal.c                       t t| d|  d S )Nz No job by the id of %s was found)superr   __init__selfjob_id	__class__ P/var/www/html/bot/env/lib/python3.10/site-packages/apscheduler/jobstores/base.pyr   
   s   zJobLookupError.__init____name__
__module____qualname____doc__r   __classcell__r   r   r   r   r          r   c                       r   )ConflictingIdErrorz8Raised when the uniqueness of job IDs is being violated.c                    r   )Nz2Job identifier (%s) conflicts with an existing job)r   r   r   r	   r   r   r   r      s   
zConflictingIdError.__init__r   r   r   r   r   r      r   r   c                       r   )TransientJobErrorzs
    Raised when an attempt to add transient (with no func_ref) job to a persistent job store is
    detected.
    c                    r   )NzgJob (%s) cannot be added to this job store because a reference to the callable could not be determined.)r   r   r   r	   r   r   r   r      s
   
zTransientJobError.__init__r   r   r   r   r   r      s    r   c                   @   s   e Zd ZdZdZdZedZdd Z	dd Z
dd	 Zed
d Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zdd ZdS )BaseJobStorezSAbstract base class that defines the interface that every job store must implement.Nzapscheduler.jobstoresc                 C   s    || _ || _td| | _dS )ax  
        Called by the scheduler when the scheduler is being started or when the job store is being
        added to an already running scheduler.

        :param apscheduler.schedulers.base.BaseScheduler scheduler: the scheduler that is starting
            this job store
        :param str|unicode alias: alias of this job store as it was assigned to the scheduler
        zapscheduler.jobstores.%sN)
_scheduler_aliaslogging	getLogger_logger)r
   	scheduleraliasr   r   r   start)   s   
zBaseJobStore.startc                 C      dS )z2Frees any resources still bound to this job store.Nr   r
   r   r   r   shutdown7       zBaseJobStore.shutdownc                 C   sN   t |D ] \}}|jd ur$|dkr!|d | }|d |= ||  d S qd S )Nr   )	enumeratenext_run_timeextend)r
   jobsijobpaused_jobsr   r   r   _fix_paused_jobs_sorting:   s   


z%BaseJobStore._fix_paused_jobs_sortingc                 C   r"   )aG  
        Returns a specific job, or ``None`` if it isn't found..

        The job store is responsible for setting the ``scheduler`` and ``jobstore`` attributes of
        the returned job to point to the scheduler and itself, respectively.

        :param str|unicode job_id: identifier of the job
        :rtype: Job
        Nr   r	   r   r   r   
lookup_jobC   r%   zBaseJobStore.lookup_jobc                 C   r"   )a  
        Returns the list of jobs that have ``next_run_time`` earlier or equal to ``now``.
        The returned jobs must be sorted by next run time (ascending).

        :param datetime.datetime now: the current (timezone aware) datetime
        :rtype: list[Job]
        Nr   )r
   nowr   r   r   get_due_jobsO   r%   zBaseJobStore.get_due_jobsc                 C   r"   )z
        Returns the earliest run time of all the jobs stored in this job store, or ``None`` if
        there are no active jobs.

        :rtype: datetime.datetime
        Nr   r#   r   r   r   get_next_run_timeY   r%   zBaseJobStore.get_next_run_timec                 C   r"   )a  
        Returns a list of all jobs in this job store.
        The returned jobs should be sorted by next run time (ascending).
        Paused jobs (next_run_time == None) should be sorted last.

        The job store is responsible for setting the ``scheduler`` and ``jobstore`` attributes of
        the returned jobs to point to the scheduler and itself, respectively.

        :rtype: list[Job]
        Nr   r#   r   r   r   get_all_jobsb   r%   zBaseJobStore.get_all_jobsc                 C   r"   )z
        Adds the given job to this store.

        :param Job job: the job to add
        :raises ConflictingIdError: if there is another job in this store with the same ID
        Nr   r
   r+   r   r   r   add_jobo   r%   zBaseJobStore.add_jobc                 C   r"   )z
        Replaces the job in the store with the given newer version.

        :param Job job: the job to update
        :raises JobLookupError: if the job does not exist
        Nr   r3   r   r   r   
update_jobx   r%   zBaseJobStore.update_jobc                 C   r"   )z
        Removes the given job from this store.

        :param str|unicode job_id: identifier of the job
        :raises JobLookupError: if the job does not exist
        Nr   r	   r   r   r   
remove_job   r%   zBaseJobStore.remove_jobc                 C   r"   )z!Removes all jobs from this store.Nr   r#   r   r   r   remove_all_jobs   r%   zBaseJobStore.remove_all_jobsc                 C   s   d| j j S )Nz<%s>)r   r   r#   r   r   r   __repr__   s   zBaseJobStore.__repr__)r   r   r   r   r   r   r   r   r   r!   r$   r-   r   r.   r0   r1   r2   r4   r5   r6   r7   r8   r   r   r   r   r   "   s2    
	

	





r   )abcr   r   r   sixKeyErrorr   r   
ValueErrorr   with_metaclassr   r   r   r   r   <module>   s    