o
    4ñÕfu  ã                   @   sN   d Z ddlmZ ddlmZ ddlZddlZddlmZ G dd„ dej	ƒZ	dS )z"Classes related to cdrom handling.é    )Úprint_function)ÚOptionalN)ÚCdromProgressc                   @   s:   e Zd ZdZ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   sb   t j | ¡ |d u rtƒ | _n|| _|d urt j d|¡ |r(t j dd¡ d S t j dd¡ d S )NzAcquire::cdrom::mountzAPT::CDROM::NoMountÚtrueÚfalse)Úapt_pkgr   Ú__init__r   Ú	_progressÚconfigÚset)ÚselfÚprogressÚ
mountpointÚnomount© r   ú+/usr/lib/python3/dist-packages/apt/cdrom.pyr	   1   s   
zCdrom.__init__c                 C   ó   t j | |p| j¡S )zAdd cdrom to the sources.list.)r   r   Úaddr
   ©r   r   r   r   r   r   A   ó   z	Cdrom.addc                 C   r   )zIdentify the cdrom.)r   r   Úidentr
   r   r   r   r   r   F   r   zCdrom.identc              	   C   s¦   |   ¡ }|du r
dS t tj d¡d ¡}| tj d¡¡ |D ]0}t|ƒ�"}|D ]}| ¡  	d¡s@||v r@ W d  ƒ  dS q)W d  ƒ n1 sKw   Y  q d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   Úfind_dirÚappendÚ	find_fileÚopenÚlstripÚ
startswith)r   Úcd_idÚsrcÚfnameÚfobjÚliner   r   r   Úin_sources_listK   s    
ý€ÿ€zCdrom.in_sources_list)NNT)N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   Úpropertyr&   r   r   r   r   r       s    


r   )
r*   Ú
__future__r   Útypingr   r   r   Úapt.progress.baser   r   r   r   r   r   Ú<module>   s   