
    :cq                     \   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 G d de          Z	d\  Z
ZZZ G d d          Z G d d	ee          Zd
ej        v rej        d
         dk    rdZndZd Zedk    r e              e            Ze                    ed           e                                 e                    d          Ze                    d          Ze                                  eej                    eej                    ee            ee           dS dS )    )print_functionNc                       e Zd ZdS )DebconfErrorN)__name__
__module____qualname__     )/usr/lib/python3/dist-packages/debconf.pyr   r   "   s        Dr
   r   )lowmediumhighcriticalc                   P    e Zd ZdZddZd Zd Zd Zd Zd	 Z	d
 Z
d Zd Zd ZdS )DebconfaT  A class that speaks the debconf protocol.

    The simplest way to use this is as a context manager:

        import debconf

        with debconf.Debconf(run_frontend=True) as db:
            print(db.get('debconf/frontend'))

    Note that this will send the STOP command on exiting the context
    manager, so you shouldn't expect to be able to use the same frontend
    again after this.  If you need to do that, then you should instantiate
    the class directly instead:

        import debconf

        db = debconf.Debconf(run_frontend=True)
        print(db.get('debconf/frontend'))
    NFc                     d                                 D ]}|                     |           |pt          j        | _        |pt          j        | _        t          j        t          _        |rt                       | 	                    |           d S )Nzcapb 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runFrontEndsetUp)selftitler   r   run_frontendcommands         r   __init__zDebconf.__init__<   s    . 05uww	% 	%G OOG$$$$%CI	(cj
Z
 	MMM

5r
   c                    |                      d          | _         | j         d d         dk    rt          dd| j         z            |                                                                 | _        |r|                     |           d S d S )N   z2.   zwrong version: %s)versionr   capbr   capabilitiesr   )r   r   s     r   r   zDebconf.setUpI   s    ||A<t##s$7$,$FGGG IIKK--// 	JJu	 	r
   c                 4     t            fd           d S )Nc                  &     j         g| R i |S N)r    )argskwr    r   s     r   <lambda>z$Debconf.setCommand.<locals>.<lambda>S   s#    <4<#E$#E#E#E"#E#E r
   )setattr)r   r    s   ``r   r   zDebconf.setCommandQ   s8    gEEEEE	G 	G 	G 	G 	Gr
   c           
         |                                 }| j                            |dd                    t          t          |                    d           | j                                         	 	 | j                                                            d          }n-# t          $ r }|j
        t          j        k    rY d }~S d }~ww xY wd|v r|                    dd          \  }}n|d}}t          |          }|dk    r|S |dk    rgd}t          j        d|          D ]M}|                    d          r1t!          |          d	k    r|d         d
k    r|dz  }<||d         z  }H||z  }N|S t#          ||          )N 
T    r   z(\\.)\r#   n)upperr   joinmapstrflushr   readlinerstripIOErrorerrnoEINTRr   intre
startswithlenr   )	r   r    paramsrespestatusdata	unescapedchunks	            r   r    zDebconf.commandU   s   --//
gggsxxC8H8H/I/I/I/IJKKK
	y))++22488   7ek))HHHH	 $;;::c1--LFDDDFVQ;;Kq[[I(D11 ' '##D)) 'c%jjAooQx3!T)		!U1X-		&IIvt,,,s   6,B# #
C-CCCc                 l    | j                              d           | j                                          d S )NzSTOP
)r   r:   r   s    r   stopzDebconf.stopy   s2    
"""
r
   c                     	 |                      ||           dS # t          $ r}|j        d         dk    r Y d }~nd }~ww xY wdS )Nr2   r      )inputr   r+   )r   priorityquestionrF   s       r   
forceInputzDebconf.forceInput}   se    	JJx***1 	 	 	vayB 	 qs    
A ;A c                 8    |                      |          }|dk    S )Ntrueget)r   rR   results      r   
getBooleanzDebconf.getBoolean   s    (##r
   c                 ,    |                      |          S r*   rV   )r   rR   s     r   	getStringzDebconf.getString   s    xx!!!r
   c                     | S r*   r	   rL   s    r   	__enter__zDebconf.__enter__   s    r
   c                 .    |                                   d S r*   )rM   )r   exc_type	exc_valueexc_tbs       r   __exit__zDebconf.__exit__   s    		r
   )NNNF)r   r   r   __doc__r!   r   r   r    rM   rS   rY   r[   r]   rb   r	   r
   r   r   r   '   s         (     G G G"- "- "-H         " " "      r
   r   c                   ,     e Zd Zd fd	Zd Zd Z xZS )DebconfCommunicatorNFc                     dd|g}t          j        |t           j        t           j        dd          | _        t	          t
          |                               || j        j        | j        j                   |rt          j	        | j
                                        t          j        t          j                   t          j	        | j                                        t          j        t          j                   d S d S )Nzdebconf-communicatez-fnoninteractiveT)r   r   	close_fdsuniversal_newlines)r   r   r   )
subprocessPopenPIPEdccommsuperre   r!   r   r   fcntlr   filenoF_SETFD
FD_CLOEXECr   )r   ownerr   cloexecr+   	__class__s        r   r!   zDebconfCommunicator.__init__   s    %'95A &

t5 5 5 	!4((117;{7I8<8I 	2 	K 	K 	K  	NK	((**EM5;KLLLK
))++U]E<LMMMMM	N 	Nr
   c                     | j         ^| j         j                                         | j         j                                         | j                                          d | _         d S d S r*   )rl   r   closer   waitrL   s    r   shutdownzDebconfCommunicator.shutdown   s_    ;"K##%%%K$$&&&KDKKK	 #"r
   c                 R    	 |                                   d S # t          $ r Y d S w xY wr*   )rx   AttributeErrorrL   s    r   __del__zDebconfCommunicator.__del__   s:    	MMOOOOO 	 	 	DD	s    
&&)NF)r   r   r   r!   rx   r{   __classcell__)rt   s   @r   re   re      sa        
N 
N 
N 
N 
N 
N        r
   re   DEBCONF_USE_CDEBCONFr3   z/usr/lib/cdebconf/debconfz/usr/share/debconf/frontendc                      dt           j        vrIdt           j        d<   t          j        t          t          t          j        gt          j        z              d S d S )NDEBIAN_HAS_FRONTEND1PERL_DL_NONLAZY)osenvironexecv_frontEndProgramr   
executableargvr	   r
   r   r   r      sL    BJ..&)
$%
!$4cn#Ech#NOOOOO /.r
   __main__z&bsdmainutils/calendar_lib_is_not_emptyzless/add_mime_handlerzapt-listchanges/email-address) 
__future__r   r   r   r>   rA   ri   rn   	Exceptionr   LOWMEDIUMHIGHCRITICALr   objectre   r   r   r   r   dbrS   gorY   lessr[   aptlcrM   printr%   r'   r	   r
   r   <module>r      s  4 & % % % % %   				     	 	 	 	 	9 	 	 	 B VT8j j j j j j j jZ    '6   8 bj((J%&",,24P P P zKMMM	BMM(DEEEEEGGG==011DLL899EGGIII	E"*	E"/	E$KKK	E%LLLLL r
   