3
	`                 @   s8   d dl mZ d dlZd dlZdd Zdd Zdd ZdS )	    )print_functionNc             C   sR   |d }|d }| j | | j| d  }| j| d }|dkrJd}|d8 }||fS )z
    get the (year, month) tuple when the maintenance for the distribution
    ends. Needs the data of the release and the number of months that
    its is supported as input
       r      )ZyearZmonth)Zrelease_dateZm_monthsZyearsZmonthsZsupport_end_yearZsupport_end_month r   +/usr/lib/python3/dist-packages/apt/utils.pyget_maintenance_end_date   s    r   c          	   C   sd   |  st jj|  rdS t jtj| 2}tj|}t|}d|krHdS |d }tj|S Q R X dS )zF
    return the release date as time_t for the given release file
    NZDate)	ospathexistsfdopenapt_pkgZopen_maybe_clear_signed_fileZTagFilenextZstr_to_time)r	   datatagZsectionZdater   r   r   "get_release_date_from_release_file-   s    
r   c             C   s  || krdS | | }d}xZ|j jD ]N}|dks"|jdkr:q"x4|jD ]*\}}|j|krB|j|krB|j|krB|}qBW q"W |s|dS | jj|jd d }	x| jjD ]v}
xp|
j	D ]f}|	o|	j
|j
ko|	jrtjjd}x>dD ]6}tj|
jd|
j|f  }tjj|| r|| S qW qW qW dS )z- get the release file that provides this pkg Nr   zDir::State::lists	InReleaseReleasezdists_%s_%s)r   r   )Z_pkgZversion_listZ	file_listoriginlabelarchiveZ_listZ
find_indexlistZindex_filesZdescribeZ
is_trustedr   configZfind_dirZuri_to_filenameZuriZdistr   r	   r
   )cacheZpkgnamer   releasepkgZverZaverZver_fileZ_indexZ	indexfileZ	metaindexmdirnameZrelfilenamer   r   r   get_release_filename_for_pkg=   s6    




r   )Z
__future__r   r   r   r   r   r   r   r   r   r   <module>   s
   