U
    i©¹dÕ  ã                   @   s    d dl mZ G dd„ deƒZdS )é    )Ú
SoSPrepperc                   @   s   e Zd ZdZdZdd„ ZdS )ÚHostnamePrepperaw  
    Prepper for providing domain and hostname information to the hostname
    mapping.

    The items from hostname sources are handled manually via the _get_items
    method, rather than passing the file directly, as the parser does not know
    what hostnames or domains to match on initially.

    This will also populate the regex_items list with local short names.
    Úhostnamec                 C   s:  g }d}|j rd}n
|jrd}| |¡}|r¦|dkr¦| d¡}t|ƒdkrl| |d ¡ | jd  |d ¡ t|ƒdkr˜d |d	d … ¡}| | 	¡ ¡ | | 	¡ ¡ | d
¡}| 
¡ D ]b}| d¡s¸d|krÐq¸| ¡ dd … }	|	D ]4}
t|
 d¡ƒdkr| jd  |
¡ qä| |
¡ qäq¸| jjD ]}| |¡ q$|S )Nr   zsos_commands/host/hostnamez"data/insights_commands/hostname_-fZ	localhostÚ.é   r   é   éþÿÿÿz	etc/hostsú#)Zis_sosZis_insightsZget_file_contentÚsplitÚlenÚappendZregex_itemsÚaddÚjoinÚstripÚ
splitlinesÚ
startswithZoptsÚdomains)ÚselfÚarchiveÚitemsZ_fileZcontentr   Z
top_domainZ_hostsÚlineZhostlnZhostZdomain© r   ú?/usr/lib/python3/dist-packages/sos/cleaner/preppers/hostname.pyÚ_get_items_for_hostname   s8    


z'HostnamePrepper._get_items_for_hostnameN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Únamer   r   r   r   r   r      s   r   N)Zsos.cleaner.preppersr   r   r   r   r   r   Ú<module>   s   