File: //lib/python3/dist-packages/twisted/names/__pycache__/hosts.cpython-310.pyc
o
�b� � @ sz d Z ddlmZ ddlmZmZ ddlmZmZ ddl m
Z
ddlmZ ddl
mZ dd � Zd
d� ZG dd
� d
ej�ZdS )z
hosts(5) support.
� )�defer)�isIPAddress�
isIPv6Address)�common�dns)�failure)�nativeString)�FilePathc C s� g }z| � � �� }W n ty | Y S w |�� }|D ]F}|�d�}|dkr-|d|� }|s0q|�� }|�� dd� |dd� D �v rbzt|d �}W n tyT Y qw t|�s]t |�rb|�
|� q|S )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.
� #���Nc S s g | ]}|� � �qS � )�lower)�.0�sr r �5/usr/lib/python3/dist-packages/twisted/names/hosts.py�
<listcomp>/ s z$searchFileForAll.<locals>.<listcomp>� r )�
getContent�
splitlines�
BaseExceptionr
�find�splitr �
ValueErrorr r �append)� hostsFile�name�results�lines�line�idx�parts�maybeIPr r r �searchFileForAll s0 �
�
�r"