
ý Ó\S  ã               @   sy  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z Gd d „  d e ƒ Z	 d \ Z
 Z Z Z Gd	 d
 „  d
 ƒ Z Gd d „  d e e ƒ Z d e j k r× e j d d k r× d Z n d Z d d „  Z e d k rue ƒ  e ƒ  Z e j e d ƒ e j ƒ  e j d ƒ Z e j d ƒ Z e j ƒ  e e j ƒ e e j ƒ e e ƒ e e ƒ d S)é    )Úprint_functionNc               @   s   e  Z d  Z d S)ÚDebconfErrorN)Ú__name__Ú
__module__Ú__qualname__© r   r   ú)/usr/lib/python3/dist-packages/debconf.pyr   "   s   r   ÚlowÚmediumÚhighÚcriticalc               @   sy   e  Z d  Z d d d d d „ Z d d „  Z d d „  Z d d	 „  Z d
 d „  Z d d „  Z d d „  Z	 d d „  Z
 d S)ÚDebconfNc             C   se   x! d j  ƒ  D] } |  j | ƒ q W| p0 t j |  _ | pB t j |  _ t j t _ |  j | ƒ d  S)Nz©capb set reset title input beginblock endblock go get register unregister subst fset fget previous_module visible purge metaget exist version settitle info progress data)	ÚsplitÚ
setCommandÚsysÚstdinÚreadÚstdoutÚwriteÚstderrÚsetUp)ÚselfÚtitler   r   Úcommandr   r   r   Ú__init__)   s    zDebconf.__init__c             C   sm   |  j  d ƒ |  _  |  j  d  d … d k rA t d d |  j  ƒ ‚ |  j ƒ  j ƒ  |  _ | ri |  j | ƒ d  S)Né   z2.é   zwrong version: %s)Úversionr   Zcapbr   Úcapabilitiesr   )r   r   r   r   r   r   4   s    zDebconf.setUpc                s#   t  ˆ ˆ  ‡  ‡ f d d †  ƒ d  S)Nc                 s   ˆ j  ˆ  |  | Ž S)N)r   )ÚargsÚkw)r   r   r   r   Ú<lambda>>   s    z$Debconf.setCommand.<locals>.<lambda>)Úsetattr)r   r   r   )r   r   r   r   <   s    	zDebconf.setCommandc       	      G   s›  | j  ƒ  } |  j j d | d j t t | ƒ ƒ f ƒ |  j j ƒ  xd y |  j j ƒ  j d ƒ } PWqH t	 k
 r§ } z  | j
 t
 j k r’ wH n ‚  WYd  d  } ~ XqH XqH Wd | k rÓ | j d d ƒ \ } } n | d } } t | ƒ } | d k rü | S| d k rˆd } xs t j d | ƒ D]_ } | j d ƒ rvt | ƒ d	 k rv| d d
 k re| d 7} q€| | d 7} q!| | 7} q!W| St | | ƒ ‚ d  S)Nz%s %s
ú Ú
é   Ú r   z(\\.)ú\r   Ún)Úupperr   ÚjoinÚmapÚstrÚflushr   ÚreadlineÚrstripÚIOErrorÚerrnoZEINTRr   ÚintÚreÚ
startswithÚlenr   )	r   r   ZparamsZrespÚeÚstatusÚdataZ	unescapedÚchunkr   r   r   r   @   s6    ,!zDebconf.commandc             C   s!   |  j  j  d ƒ |  j  j ƒ  d  S)NzSTOP
)r   r-   )r   r   r   r   Ústopd   s    zDebconf.stopc             C   sZ   y |  j  | | ƒ d SWn; t k
 rU } z | j d d k rC ‚  WYd  d  } ~ Xn Xd S)Nr%   r   é   )Úinputr   r   )r   ÚpriorityÚquestionr6   r   r   r   Ú
forceInputh   s    zDebconf.forceInputc             C   s   |  j  | ƒ } | d k S)NÚtrue)Úget)r   r>   Úresultr   r   r   Ú
getBooleanq   s    zDebconf.getBooleanc             C   s   |  j  | ƒ S)N)rA   )r   r>   r   r   r   Ú	getStringu   s    zDebconf.getString)r   r   r   r   r   r   r   r:   r?   rC   rD   r   r   r   r   r   '   s   $	r   c                   s@   e  Z d  Z d d ‡  f d d † Z d d „  Z d d „  Z ‡  S)	ÚDebconfCommunicatorNFc          
      s¾   d d | g } t  j | d t  j d t  j d d d d ƒ|  _ t t |  ƒ j d | d	 |  j j d
 |  j j ƒ | rº t	 j	 |  j
 j ƒ  t	 j t	 j ƒ t	 j	 |  j j ƒ  t	 j t	 j ƒ d  S)Nzdebconf-communicatez-fnoninteractiver   r   Ú	close_fdsTÚuniversal_newlinesr   r   r   )Ú
subprocessÚPopenÚPIPEÚdccommÚsuperrE   r   r   r   Úfcntlr   ÚfilenoZF_SETFDZ
FD_CLOEXECr   )r   Úownerr   Zcloexecr   )Ú	__class__r   r   r   z   s    "zDebconfCommunicator.__init__c             C   sI   |  j  d  k	 rE |  j  j j ƒ  |  j  j j ƒ  |  j  j ƒ  d  |  _  d  S)N)rK   r   Úcloser   Úwait)r   r   r   r   Úshutdown†   s
    zDebconfCommunicator.shutdownc             C   s'   y |  j  ƒ  Wn t k
 r" Yn Xd  S)N)rS   ÚAttributeError)r   r   r   r   Ú__del__Ž   s    zDebconfCommunicator.__del__)r   r   r   r   rS   rU   r   r   )rP   r   rE   y   s   rE   ZDEBCONF_USE_CDEBCONFr&   z/usr/lib/cdebconf/debconfz/usr/share/debconf/frontendc               C   s@   d t  j k r< d t  j d <t  j t t t j g t j ƒ d  S)NZDEBIAN_HAS_FRONTENDÚ1ZPERL_DL_NONLAZY)ÚosÚenvironÚexecvÚ_frontEndProgramr   Ú
executableÚargvr   r   r   r   ÚrunFrontEnd›   s    r]   Ú__main__z&bsdmainutils/calendar_lib_is_not_emptyzless/add_mime_handlerzapt-listchanges/email-address)r	   r
   r   r   ) Ú
__future__r   r   rW   r1   r3   rH   rM   Ú	Exceptionr   ZLOWZMEDIUMZHIGHZCRITICALr   ÚobjectrE   rX   rZ   r]   r   Údbr?   ÚgorC   ZlessrD   Zaptlcr:   Úprintr   r   r   r   r   r   Ú<module>   s4   R		


