
    h                         S r SSKJr   " S S\5      r " S S\5      r " S S\5      r " S	 S
\5      r " S S5      r " S S5      r	 " S S\5      r
 " S S\5      rg)z
Parser for inetd.conf files
    )Optionalc                       \ rS rSrSrSrg)InvalidConfError   z
Invalid configuration file
 N__name__
__module____qualname____firstlineno____doc____static_attributes__r       _/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/runner/inetdconf.pyr   r          r   r   c                       \ rS rSrSrSrg)InvalidInetdConfError   z
Invalid inetd.conf file
r   Nr   r   r   r   r   r      r   r   r   c                       \ rS rSrSrSrg)InvalidServicesConfError   z
Invalid services file
r   Nr   r   r   r   r   r      r   r   r   c                       \ rS rSrSrSrg)UnknownService   z
Unknown service name
r   Nr   r   r   r   r   r      r   r   r   c                   H    \ rS rSr% SrSrSr\\   \	S'   S
S jr
S rS rS	rg)SimpleConfFile%   z
Simple configuration file parser superclass.

Filters out comments and empty lines (which includes lines that only
contain comments).

To use this class, override parseLine or parseFields.
#NdefaultFilenamec                    SnUc(  U R                   (       a  [        U R                   5      nSn UR                  5        HS  nUR                  U R                  5      nUS:w  a  USU nUR                  5       nU(       d  MB  U R                  U5        MU     U(       a  UR                  5         gg! U(       a  UR                  5         f f = f)zw
Parse a configuration file

If file is None and self.defaultFilename is set, it will open
defaultFilename and use it.
FNT)r   open	readlinesfindcommentCharstrip	parseLineclose)selffiler(   linecomments        r   	parseFileSimpleConfFile.parseFile2   s     <D00,,-DE	())D$4$45b=>D zz| t$ ) 

 u

 s   A'B/ /C	c                      U R                   " UR                  5       6   g! [         a    [        S[	        U5      -   5      ef = f)zu
Override this.

By default, this will split the line on whitespace and call
self.parseFields (catching any errors).
zInvalid line: N)parseFieldssplit
ValueErrorr   repr)r)   r+   s     r   r'   SimpleConfFile.parseLineQ   sB    	Gdjjl+ 	G'(84:(EFF	Gs	     "Ac                     g)z
Override this.
Nr   )r)   fieldss     r   r0   SimpleConfFile.parseFields]   s    r   r   N)r	   r
   r   r   r   r%   r   r   str__annotations__r-   r'   r0   r   r   r   r   r   r   %   s,     K%)OXc])>
Gr   r   c                   B    \ rS rSrSrSrSrSrSrSr	Sr
SrSrSrS rSrg)InetdServicec   z+
A simple description of an inetd service.
Nc
                 p    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        g r8   )	nameport
socketTypeprotocolwaitusergroupprogramprogramArgs)
r)   r?   r@   rA   rB   rC   rD   rE   rF   rG   s
             r   __init__InetdService.__init__r   s2     		$ 		
&r   )	rE   r?   r@   rF   rG   rB   rA   rD   rC   )r	   r
   r   r   r   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   r   r   r   r   r<   r<   c   s;     DDJHDDEGK'r   r<   c                   ,    \ rS rSrSrSrSS jrS rSrg)		InetdConf   z6
Configuration parser for a traditional UNIX inetd(8)
z/etc/inetd.confNc                 X    / U l         Uc  [        5       nUR                  5         Xl        g r8   )servicesServicesConfr-   knownServices)r)   rP   s     r   rH   InetdConf.__init__   s(     (NM##%*r   c                 t   UR                  S5      S/-   SS u  pXU R                  R                  R                  X4S5      n	U	(       d$  UR	                  S5      (       d   [        U5      n	SnU R                  R                  [        UU	UUUUUUU5	      5        g! [         a    [        SU SU S35      ef = f)	z`
Parse an inetd.conf file.

Implemented from the description in the Debian inetd.conf man page.
.N   zrpc/unknownzUnknown service: z ())
r1   rP   rN   get
startswithintBaseExceptionr   appendr<   )
r)   serviceNamerA   rB   rC   rD   rF   rG   rE   r@   s
             r   r0   InetdConf.parseFields   s     zz#$/!4 !!**../FMH//77U;'' 	
	
 ! U$'8RzQR%STTUs    B B7)rP   rN   r8   	r	   r
   r   r   r   r   rH   r0   r   r   r   r   rK   rK      s     (O+"
r   rK   c                   (    \ rS rSrSrSrS rS rSrg)rO      z^
/etc/services parser

@ivar services: dict mapping service names to (port, protocol) tuples.
z/etc/servicesc                     0 U l         g r8   rN   )r)   s    r   rH   ServicesConf.__init__   s	    r   c                      UR                  S5      u  pE[        U5      nX@R
                  X4'   U H  nX@R
                  Xe4'   M     g ! [         a    [        S[	        U5       35      ef = f)N/zInvalid port/protocol: )r1   rY   rZ   r   r3   rN   )r)   r?   portAndProtocolaliasesr@   rB   aliass          r   r0   ServicesConf.parseFields   sz    	,2237NDt9D +/t&'E/3MM5+,   	*)$*?)@A 	s   A "A*rb   Nr^   r   r   r   rO   rO      s     &O4r   rO   N)r   typingr   	Exceptionr   r   r   r   r   r<   rK   rO   r   r   r   <module>rl      so   
 y , / Y ; ;|' ':1
 1
h4> 4r   