o
    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   s6  g }d}|j r
d}n|jrd}| |¡}|rS|dkrS| d¡}t|ƒdkr6| |d ¡ | jd  |d ¡ t|ƒdkrLd |d	d … ¡}| | 	¡ ¡ | | 	¡ ¡ | d
¡}| 
¡ D ]0}| d¡sgd|v rhq\| ¡ dd … }	|	D ]}
t|
 d¡ƒdkr†| jd  |
¡ qr| |
¡ qrq\| jjD ]}| |¡ q‘|S )Nr   zsos_commands/host/hostnamez"data/insights_commands/hostname_-fÚ	localhostÚ.é   r   é   éþÿÿÿz	etc/hostsú#)Úis_sosÚis_insightsÚget_file_contentÚsplitÚlenÚappendÚregex_itemsÚaddÚjoinÚstripÚ
splitlinesÚ
startswithÚoptsÚdomains)ÚselfÚarchiveÚitemsÚ_fileÚcontentr   Ú
top_domainÚ_hostsÚlineÚhostlnÚhostÚdomain© r$   ú?/usr/lib/python3/dist-packages/sos/cleaner/preppers/hostname.pyÚ_get_items_for_hostname   s:   


üz'HostnamePrepper._get_items_for_hostnameN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Únamer&   r$   r$   r$   r%   r      s    r   N)Úsos.cleaner.preppersr   r   r$   r$   r$   r%   Ú<module>   s   
