
    +fv                    T   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d dlm	Z	 d dl
mZmZ  G d de      Z G d de      Zd	\  ZZZZ G d
 d      Z G d de      Zdej,                  v rej,                  d   dk7  rdZndZddddZedk(  r ed        e       Zej7                  ed       ej9                          ej;                  d      Zej?                  d      Z ejC                           e"ejF                          e"ejH                          e"e        e"e        yy)    )annotationsN)TracebackType)IOProtocolc                      e Zd ZddZy)Commandc                     y N )selfparamss     )/usr/lib/python3/dist-packages/debconf.py__call__zCommand.__call__'   s        N)r   	str | intreturnstr)__name__
__module____qualname__r   r   r   r   r   r   &   s    r   r   c                      e Zd Zy)DebconfErrorN)r   r   r   r   r   r   r   r   +   s    r   r   )lowmediumhighcriticalc                  V   e Zd ZU dZded<   ded<   ded<   ded<   ded<   ded<   ded	<   ded
<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   de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+d Z	 	 	 	 	 	 	 	 d,d!Zy)-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'))
    r   
beginblockcapbendblockexistfsetgetgoinfoinputprogresspurgeregisterresetsetsettitlesubsttitle
unregisterversion_visibleNc                    dj                         D ]  }| j                  |        |xs t        j                  | _        |xs t        j
                  | _        t        j                  t        _        |r
t                | j                  |       y )Nzcapb set reset title input beginblock endblock go get register unregister subst fset fget visible purge metaget exist version_ settitle info progress data)
split
setCommandsysstdinreadstdoutwritestderrrunFrontEndsetUp)r   r/   r8   r:   run_frontendcommands         r   __init__zDebconf.__init__\   sk    " %'	%G OOG$	% %CII	(cjj
ZZ
M

5r   c                    | j                  d      | _        | j                  d d dk7  rt        dd| j                  z        | j                         j	                         | _        |r| j                  |       y y )N   z2.   zwrong version: %s)r1   versionr   r    r4   capabilitiesr/   )r   r/   s     r   r=   zDebconf.setUpq   sg    }}Q'<<t#s$7$,,$FGG IIK--/JJu r   c                *     t          fd       y )Nc                 0     j                   g| i |S r
   )r?   )argskwr?   r   s     r   <lambda>z$Debconf.setCommand.<locals>.<lambda>}   s    W Bt Br B r   )setattr)r   r?   s   ``r   r5   zDebconf.setCommandy   s    B	
r   c                   |dk(  rd}|j                         }| j                  j                  dj                  |dj                  t	        t
        |                         | j                  j                          	 	 | j                  j                         j                  d      }	 d|v r|j                  dd      \  }}n|d}}t        |      }|dk(  r|S |dk(  rZd}t        j                  d	|      D ]=  }	|	j!                  d
      r%t#        |	      dk(  r|	d   dk(  r|dz  }0||	d   z  }9||	z  }? |S t%        ||      # t        $ r(}|j                  t        j                  k(  rY d }~ d }~ww xY w)Nr1   rD   z{} {}
 
    r   z(\\.)\rB   n)upperr:   formatjoinmapr   flushr8   readlinerstripOSErrorerrnoEINTRr4   intre
startswithlenr   )
r   r?   r   respestatus_datastatus	unescapedchunks
             r   r?   zDebconf.command   sd   j G--/

))'388CV<L3MNO

yy))+2248 $; JJsA.MGT "TGWQ;Kq[I(D1 '##D)c%jAoQx3!T)	!U1X-	&I' vt,,3  77ekk)	s   <)E 	E2
E-,E--E2c                n    | j                   j                  d       | j                   j                          y )NzSTOP
)r:   rW   r   s    r   stopzDebconf.stop   s$    

"

r   c                |    	 | j                  ||       y# t        $ r}|j                  d   dk7  r Y d }~yd }~ww xY w)NrO   r      )r'   r   rH   )r   priorityquestionrb   s       r   
forceInputzDebconf.forceInput   sB    	JJx* 	vvayB 	s    	;6;c                .    | j                  |      }|dk(  S )Ntruer$   )r   rn   results      r   
getBooleanzDebconf.getBoolean   s    (#r   c                $    | j                  |      S r
   rr   )r   rn   s     r   	getStringzDebconf.getString   s    xx!!r   c                    | S r
   r   ri   s    r   	__enter__zDebconf.__enter__   s    r   c                $    | j                          y r
   )rj   )r   exc_type	exc_valueexc_tbs       r   __exit__zDebconf.__exit__   s     			r   )NNNF)
r/   
str | Noner8   IO[str] | Noner:   r   r>   boolr   None)r/   r~   r   r   )r?   r   r   r   )r?   r   r   r   r   r   r   r   )rm   r   rn   r   r   r]   )rn   r   r   r   )rn   r   r   r   )r   r   )rz   ztype[BaseException] | Noner{   zBaseException | Noner|   zTracebackType | Noner   r   )r   r   r   __doc____annotations__r@   r=   r5   r?   rj   ro   rt   rv   rx   r}   r   r   r   r   r   2   s   ( 
MN
M	LK
MNNN	LNN !# $"  	
  
*
$-L ", ( %	
 
r   r   c                  B     e Zd Z	 d	 	 	 	 	 	 	 d fdZddZddZ xZS )DebconfCommunicatorc                ,   dd|g}t        j                  |t         j                  t         j                  dd      | _        t        |   || j                  j                  | j                  j                         |rt        j                  | j                  j                         t        j                  t        j                         t        j                  | j                  j                         t        j                  t        j                         y y )Nzdebconf-communicatez-fnoninteractiveT)r7   r9   	close_fdsuniversal_newlines)r/   r8   r:   )
subprocessPopenPIPEdccommsuperr@   r9   r7   fcntlr8   filenoF_SETFD
FD_CLOEXECr:   )r   ownerr/   cloexecrH   	__class__s        r   r@   zDebconfCommunicator.__init__   s     &'95A4>4D4D//??#5
 	dkk008I8I 	 	
 KK		((*EMM5;K;KLKK

))+U]]E<L<LM r   c                P   | j                   | j                   j                  J | j                   j                  J | j                   j                  j                          | j                   j                  j                          | j                   j	                          d | _         y y r
   )r   r7   r9   closewaitri   s    r   shutdownzDebconfCommunicator.shutdown   s    ;;";;$$000;;%%111KK##%KK$$&KKDK #r   c                D    	 | j                          y # t        $ r Y y w xY wr
   )r   AttributeErrorri   s    r   __del__zDebconfCommunicator.__del__   s"    	MMO 		s    	)NF)r   r   r/   r~   r   r   r   r   r   )r   r   r   r@   r   r   __classcell__)r   s   @r   r   r      s:    DINN!+N=AN	N$r   r   DEBCONF_USE_CDEBCONFrP   z/usr/lib/cdebconf/debconfz/usr/share/debconf/frontendF)pass_sys_executablec                   dt         j                  vrudt         j                  d<   t        g}| r|j                  t        j
                         |j                  t        j                         t        j                  t        |       y y )NDEBIAN_HAS_FRONTEND1PERL_DL_NONLAZY)	osenviron_frontEndProgramappendr6   
executableextendargvexecv)r   rH   s     r   r<   r<      s\    BJJ.(+

$% !KK'CHH
!4( /r   __main__Tz&bsdmainutils/calendar_lib_is_not_emptyzless/add_mime_handlerzapt-listchanges/email-address)r   r   r   r   )%
__future__r   r[   r   r   r^   r   r6   typesr   typingr   r   r   	Exceptionr   LOWMEDIUMHIGHCRITICALr   r   r   r   r<   r   dbro   r%   rt   lessrv   aptlcrj   printrD   rE   r   r   r   <module>r      s  4 #   	 	  
  h 
	9 	 B VT8Q Qh!' !J bjj(


)*b024 05 ) zD)	BMM(DEEEG==01DLL89EGGI	"**	"//	$K	%L r   