

`                 @   s[   d  Z  d d l m Z d d l Z d d l Z d d l m Z Gd d   d e j  Z d S)z"Classes related to cdrom handling.    )print_functionN)CdromProgressc               @   s[   e  Z d  Z d Z d d d d d  Z d d d  Z d d d	  Z e d
 d    Z d S)Cdroma;  Support for apt-cdrom like features.

    This class has several optional parameters for initialisation, which may
    be used to influence the behaviour of the object:

    The optional parameter `progress` is a CdromProgress() subclass, which will
    ask for the correct cdrom, etc. If not specified or None, a CdromProgress()
    object will be used.

    The optional parameter `mountpoint` may be used to specify an alternative
    mountpoint.

    If the optional parameter `nomount` is True, the cdroms will not be
    mounted. This is the default behaviour.
    NTc             C   s   t  j j |   | d  k r+ t   |  _ n	 | |  _ | d  k	 rS t  j j d |  | ro t  j j d d  n t  j j d d  d  S)NzAcquire::cdrom::mountzAPT::CDROM::NoMounttruefalse)apt_pkgr   __init__r   	_progressconfigset)selfprogressZ
mountpointZnomount r   +/usr/lib/python3/dist-packages/apt/cdrom.pyr   0   s    	zCdrom.__init__c             C   s   t  j j |  | p |  j  S)zAdd cdrom to the sources.list.)r   r   addr	   )r   r   r   r   r   r   ?   s    z	Cdrom.addc             C   s   t  j j |  | p |  j  S)zIdentify the cdrom.)r   r   identr	   )r   r   r   r   r   r   C   s    zCdrom.identc             C   s   |  j    } | d k r d St j t j j d  d  } | j t j j d   x[ | D]S } t |  > } x4 | D], } | j   j	 d  rw | | k rw d Sqw WWd QRXq[ Wd S)z:Check if the cdrom is already in the current sources.list.NFzDir::Etc::sourceparts*zDir::Etc::sourcelist#T)
r   globr   r
   Zfind_dirappendZ	find_fileopenlstrip
startswith)r   Zcd_idsrcfnameZfobjliner   r   r   in_sources_listG   s    "zCdrom.in_sources_list)	__name__
__module____qualname____doc__r   r   r   propertyr   r   r   r   r   r      s
   r   )r    Z
__future__r   r   r   Zapt.progress.baser   r   r   r   r   r   <module>   s
   