Your IP : 216.73.216.196
B
��d^* � @ s� d Z ddlmZmZ ddlmZ ddlmZ ddlm Z ddl
mZ ddlm
Z
ddlmZ dd lmZ d
d� Zdd
� ZG dd� dej�ZdS )z
hosts(5) support.
� )�division�absolute_import)�nativeString)�dns)�failure)�FilePath)�defer)�isIPAddress)�commonc C s� g }y| � � �� }W n
|S |�� }xh|D ]`}|�d�}|dkrP|d|� }|sVq.|�� }|�� dd� |dd� D �kr.|�t|d �� q.W |S )a�
Search the given file, which is in hosts(5) standard format, for an address
entry 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
�F/opt/alt/python37/lib64/python3.7/site-packages/twisted/names/hosts.py�
<listcomp>1 s z$searchFileForAll.<locals>.<listcomp>� r )Z
getContent�
splitlinesr �find�split�appendr )Z hostsFile�name�results�lines�line�idx�partsr
r
r �searchFileForAll s
r c C s t t| �|�}|r|d S dS )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.
r N)r r )�filer Z addressesr
r
r �
searchFileFor7 s r c @ sJ e Zd ZdZddd�Zdd� Zdd � Zd
d� Zdd
d�Zddd�Z eZ
dS )�Resolverz9
A resolver that services hosts(5) format files.
�
/etc/hosts� c C s t j�| � || _|| _d S )N)r
�ResolverBase�__init__r �ttl)�selfr r&