%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����dZddlmZddlmZmZddlmZmZddl	m
Z
ddlmZddl
mZd�Zd	�ZGd
�dej"�Zy)
z
hosts(5) support.
�)�defer)�isIPAddress�
isIPv6Address)�common�dns)�failure)�nativeString)�FilePathc���g}	|j�j�}|j�}|D]�}|j	d�}|dk7r|d|}|s�!|j�}|j�|ddD�cgc]}|j���c}vs�c	t
|d�}t|�st|�s��|j|���|S#t$r|cYSwxYwcc}w#t$rY��wxYw)a�
    Search the given file, which is in hosts(5) standard format, for addresses
    associated with a given name.

    @param hostsFile: The name of the hosts(5)-format file to search.
    @type hostsFile: L{FilePath}

    @param name: The name to search for.
    @type name: C{bytes}

    @return: L{None} if the name is not found in the file, otherwise a
        C{str} giving the address in the file associated with the name.
    �#���N�r)�
getContent�
splitlines�
BaseException�lower�find�splitr	�
ValueErrorrr�append)	�	hostsFile�name�results�lines�line�idx�parts�s�maybeIPs	         �5/usr/lib/python3/dist-packages/twisted/names/hosts.py�searchFileForAllr!s����G���$�$�&�1�1�3���:�:�<�D��(���i�i��o���"�9����:�D����
�
����:�:�<�u�Q�R�y�9�!�A�G�G�I�9�9�
�&�u�Q�x�0���7�#�}�W�'=����w�'�(��N��'������:���
��
�s)�C�;C#�C(�C �C �(	C4�3C4c�<�tt|�|�}|r|dSy)a�
    Grep given file, which is in hosts(5) standard format, for an address
    entry with a given name.

    @param file: The name of the hosts(5)-format file to search.
    @type file: C{str} or C{bytes}

    @param name: The name to search for.
    @type name: C{bytes}

    @return: L{None} if the name is not found in the file, otherwise a
        C{str} giving the first address in the file associated with
        the name.
    rN)r!r
)�filer�	addressess   r �
searchFileForr%9s$��!��$���6�I����|���c�>�eZdZdZd	d�Zd�Zd�Zd�Zd
d�Zd
d�Z	eZ
y)�Resolverz9
    A resolver that services hosts(5) format files.
    c�^�tjj|�||_||_y�N)r�ResolverBase�__init__r#�ttl)�selfr#r-s   r r,zResolver.__init__Ss$�����$�$�T�*���	���r&c�j���t��fd�tt�j���D��S)zv
        Return a tuple of L{dns.RRHeader} instances for all of the IPv4
        addresses in the hosts file.
        c3���K�|]l}t|�r_tj�tjtj�j
tj|�j
�����ny�wr*)rr�RRHeader�A�INr-�Record_A��.0�addrrr.s  ��r �	<genexpr>z%Resolver._aRecords.<locals>.<genexpr>]sM�����
���4� �
�L�L��s�u�u�c�f�f�d�h�h����T�4�8�8�8T�U�
���A2A5��tupler!r
r#�r.rs``r �	_aRecordszResolver._aRecordsXs/���
�
�(��$�)�)�)<�d�C�
�
�	
r&c�j���t��fd�tt�j���D��S)zv
        Return a tuple of L{dns.RRHeader} instances for all of the IPv6
        addresses in the hosts file.
        c3���K�|]l}t|�r_tj�tjtj�j
tj|�j
�����ny�wr*)rrr1�AAAAr3r-�Record_AAAAr5s  ��r r8z(Resolver._aaaaRecords.<locals>.<genexpr>hsR�����
���T�"�	
�L�L��c�h�h�������#�/�/�$����2Q�
�
�r9r:r<s``r �_aaaaRecordszResolver._aaaaRecordscs1���
�
�)��$�)�)�)<�d�C�	
�
�	
r&c��|rtj|ddf�Stjtjtj|���S)aF
        Generate a response for the given name containing the given result
        records, or a failure if there are no result records.

        @param name: The DNS name the response is for.
        @type name: C{str}

        @param records: A tuple of L{dns.RRHeader} instances giving the results
            that will go into the response.

        @return: A L{Deferred} which will fire with a three-tuple of result
            records, authority records, and additional records, or which will
            fail with L{dns.DomainError} if there are no result records.
        �)r�succeed�failr�Failurer�DomainError)r.r�recordss   r �_respondzResolver._respondps>����=�=�'�2�r�!2�3�3��z�z�'�/�/�#�/�/�$�*?�@�A�Ar&Nc�n�tj|�}|j||j|��S)zm
        Read any IPv4 addresses from C{self.file} and return them as
        L{Record_A} instances.
        )r�domainStringrJr=�r.r�timeouts   r �
lookupAddresszResolver.lookupAddress�s.��
����%���}�}�T�4�>�>�$�#7�8�8r&c�n�tj|�}|j||j|��S)zp
        Read any IPv6 addresses from C{self.file} and return them as
        L{Record_AAAA} instances.
        )rrLrJrBrMs   r �lookupIPV6AddresszResolver.lookupIPV6Address�s0��
����%���}�}�T�4�#4�#4�T�#:�;�;r&)s
/etc/hostsir*)�__name__�
__module__�__qualname__�__doc__r,r=rBrJrOrQ�lookupAllRecordsrDr&r r(r(Ns.����
	
�
�B�&9�<�%�r&r(N)rU�twisted.internetr�twisted.internet.abstractrr�
twisted.namesrr�twisted.pythonr�twisted.python.compatr	�twisted.python.filepathr
r!r%r+r(rDr&r �<module>r]s=��
�
#�@�%�"�.�,�$�N�*I%�v�"�"�I%r&

Zerion Mini Shell 1.0