
    h                         S r S/rSSKJr  SSKJrJrJrJrJ	r	  SSK
JrJr  \ " S S5      5       rS\S\\\4   S	\\   4S
 jrS\\\4   S	\	\   4S jrg)z
Integration with systemd.

Currently only the minimum APIs necessary for using systemd's socket activation
feature are supported.
	ListenFDs    )getpid)DictListMappingOptionalSequence)Factorydefinec                       \ rS rSr% Sr\\   \S'   \" \	5      r
\\   \S'   Sr\  SS\\\\4      S\\   S	S 4S
 jj5       rS	\\   4S jrS	\\\4   4S jrSrg)r      a  
L{ListenFDs} provides access to file descriptors inherited from systemd.

Typically L{ListenFDs.fromEnvironment} should be used to construct a new
instance of L{ListenFDs}.

@cvar _START: File descriptors inherited from systemd are always
    consecutively numbered, with a fixed lowest "starting" descriptor.  This
    gives the default starting descriptor.  Since this must agree with the
    value systemd is using, it typically should not be overridden.

@ivar _descriptors: A C{list} of C{int} giving the descriptors which were
    inherited.

@ivar _names: A L{Sequence} of C{str} giving the names of the descriptors
    which were inherited.
_descriptors_names   Nenvironstartreturnc                 
   Uc  SSK Jn  UnUc  U R                  n[        [	        5       5      UR                  S5      :X  a  [        X!5      n[        U5      nO/ nSn[        U5      [        U5      :w  a	  U " / S5      $ U " XE5      $ )a^  
@param environ: A dictionary-like object to inspect to discover
    inherited descriptors.  By default, L{None}, indicating that the
    real process environment should be inspected.  The default is
    suitable for typical usage.

@param start: An integer giving the lowest value of an inherited
    descriptor systemd will give us.  By default, L{None}, indicating
    the known correct (that is, in agreement with systemd) value will be
    used.  The default is suitable for typical usage.

@return: A new instance of C{cls} which can be used to look up the
    descriptors which have been inherited.
r   )r   
LISTEN_PID )	osr   _STARTstrr   get_parseDescriptors_parseNameslen)clsr   r   _environdescriptorsnamess         ]/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/python/systemd.pyfromEnvironmentListenFDs.fromEnvironment.   s~    ( ?.G=JJEvx=GKK55%6u%FK#.w#7EKE u:[))r2;;&&    c                 ,    [        U R                  5      $ )z&
@return: The configured descriptors.
)listr   selfs    r"   inheritedDescriptorsListenFDs.inheritedDescriptors\   s     D%%&&r%   c                 T    [        [        U R                  U R                  5      5      $ )zZ
@return: A mapping from the names of configured descriptors to
    their integer values.
)dictzipr   r   r(   s    r"   inheritedNamedDescriptors#ListenFDs.inheritedNamedDescriptorsb   s     
 CT%6%6788r%   r   )NN)__name__
__module____qualname____firstlineno____doc__r	   int__annotations__r
   tupler   r   r   classmethodr   r   r#   r   r*   r   r/   __static_attributes__r   r%   r"   r   r      s    $ 3-#ENFHSM*F 04#+''#s(+,+' }+' 
	+' +'Z'd3i '94S> 9r%   r   r   r   c                      [        US   5      n[        [        X U-   5      5      nUS	 US	 U$ ! [        [        4 a    / s $ f = f)a  
Parse the I{LISTEN_FDS} environment variable supplied by systemd.

@param start: systemd provides only a count of the number of descriptors
    that have been inherited.  This is the integer value of the first
    inherited descriptor.  Subsequent inherited descriptors are numbered
    counting up from here.  See L{ListenFDs._START}.

@param environ: The environment variable mapping in which to look for the
    value to parse.

@return: The integer values of the inherited file descriptors, in order.

LISTEN_FDSr   )r6   r'   rangeKeyError
ValueError)r   r   countr    s       r"   r   r   j   s]    GL)* 567 L!7<#8# j! 	s   / AAc                 z    U R                  SS5      n[        U5      S:  a  [        UR                  S5      5      $ g)z
Parse the I{LISTEN_FDNAMES} environment variable supplied by systemd.

@param environ: The environment variable mapping in which to look for the
    value to parse.

@return: The names of the inherited descriptors, in order.
LISTEN_FDNAMES r   :r   )r   r   r8   split)r   r!   s     r"   r   r      s7     KK("-E
5zA~U[[%&&r%   N)r5   __all__r   r   typingr   r   r   r   r	   attrsr
   r   r   r6   r   r   r   r   r%   r"   <module>rI      s   
 -  : : ! Q9 Q9 Q9h!S !738+< !c !Hc* x} r%   