§
    ÈtºfÏ  ã                   óÎ   — d Z dgZddlmZ ddlmZmZmZmZm	Z	 ddl
mZmZ e G d„ d¦  «        ¦   «         Zdedeeef         d	ee         fd
„Zdeeef         d	e	e         fd„ZdS )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                   óà   — e Zd ZU dZee         ed<    ee¦  «        Z	ee
         ed<   dZe	 	 ddeee
e
f                  dee         dd fd	„¦   «         Zdee         fd
„Zdee
ef         fd„ZdS )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                 óD  — |€ddl m} |}|€| j        }t          t	          ¦   «         ¦  «        |                     d¦  «        k    r t          ||¦  «        }t          |¦  «        }ng }d}t          |¦  «        t          |¦  «        k    r | g d¦  «        S  | ||¦  «        S )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.
        Nr   )r   Ú
LISTEN_PID© )	Úosr   Ú_STARTÚstrr   ÚgetÚ_parseDescriptorsÚ_parseNamesÚlen)Úclsr   r   Ú_environÚdescriptorsÚnamess         úU/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/python/systemd.pyÚfromEnvironmentzListenFDs.fromEnvironment.   s²   € ð( ˆ?Ø.Ð.Ð.Ð.Ð.Ð.àˆGØˆ=Ø”JˆEå�v‰xŒx‰=Œ=˜GŸKšK¨Ñ5Ô5Ò5Ð5Ý%6°u¸gÑ%FÔ%FˆKÝ#.¨wÑ#7Ô#7ˆEˆEàˆKØˆEõ ˆu‰:Œ:�˜[Ñ)Ô)Ò)Ð)Ø�3�r˜2‘;”;Ðàˆs�; Ñ&Ô&Ð&ó    c                 ó*   — t          | j        ¦  «        S )z6
        @return: The configured descriptors.
        )Úlistr   ©Úselfs    r!   ÚinheritedDescriptorszListenFDs.inheritedDescriptors\   s   € õ �DÔ%Ñ&Ô&Ð&r#   c                 óP   — t          t          | j        | j        ¦  «        ¦  «        S )zr
        @return: A mapping from the names of configured descriptors to
            their integer values.
        )ÚdictÚzipr   r   r&   s    r!   ÚinheritedNamedDescriptorsz#ListenFDs.inheritedNamedDescriptorsb   s!   € õ
 •C˜œ TÔ%6Ñ7Ô7Ñ8Ô8Ð8r#   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   ÚintÚ__annotations__r
   Útupler   r   r   Úclassmethodr   r   r"   r   r(   r   r,   r   r#   r!   r   r      sï   € € € € € € ðð ð$ ˜3”-ÐÐÑØ#˜G E™NœN€FˆH�SŒMÐ*Ð*Ñ*à€Fàð 04Ø#ð+'ð +'à˜' # s (Ô+Ô,ð+'ð ˜Œ}ð+'ð 
ð	+'ð +'ð +'ñ „[ð+'ðZ' d¨3¤ið 'ð 'ð 'ð 'ð9¨4°°S°¬>ð 9ð 9ð 9ð 9ð 9ð 9r#   r   r   r   c                 ó°   — 	 t          |d         ¦  «        }t          t          | | |z   ¦  «        ¦  «        }|d= |d= |S # t          t          f$ r g cY S w xY w)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   )r1   r%   ÚrangeÚKeyErrorÚ
ValueError)r   r   Úcountr   s       r!   r   r   j   sx   € ðÝ�G˜LÔ)Ñ*Ô*ˆõ �5 ¨°©Ñ6Ô6Ñ7Ô7ˆð �LÐ! 7¨<Ð#8ØÐøõ# •jÐ!ð ð ð Øˆ	ˆ	ˆ	ðøøøs   ‚? ¿AÁAc                 óœ   — |                       dd¦  «        }t          |¦  «        dk    r"t          |                     d¦  «        ¦  «        S dS )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   r3   Úsplit)r   r    s     r!   r   r   Ž   sF   € ð �KŠKÐ(¨"Ñ-Ô-€EÝ
ˆ5�z„z�A‚~€~Ý�U—[’[ Ñ%Ô%Ñ&Ô&Ð&Øˆ2r#   N)r0   Ú__all__r   r   Útypingr   r   r   r   r	   Úattrsr
   r   r   r1   r   r   r   r   r#   r!   ú<module>rC      s  ðð
ð ð ˆ-€à Ð Ð Ð Ð Ð Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :à !Ð !Ð !Ð !Ð !Ð !Ð !Ð !ð ðQ9ð Q9ð Q9ð Q9ð Q9ñ Q9ô Q9ñ „ðQ9ðh!˜Sð !¨7°3¸°8Ô+<ð !ÀÀcÄð !ð !ð !ð !ðH˜  c Ô*ð ¨x¸¬}ð ð ð ð ð ð r#   