Your IP : 216.73.217.13


Current Path : /usr/lib/python3/dist-packages/sos/cleaner/parsers/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/sos/cleaner/parsers/__pycache__/hostname_parser.cpython-38.pyc

U

���b�
�@s,ddlmZddlmZGdd�de�ZdS)�)�SoSCleanerParser)�SoSHostnameMapcsDeZdZdZdZdgZd
�fdd�	Zdd�Zd	d
�Zdd�Z	�Z
S)�SoSHostnameParserzHostname ParserZhostname_mapz5(((\b|_)[a-zA-Z0-9-\.]{1,200}\.[a-zA-Z]{1,63}(\b|_)))NcsJt�|_tt|��|�|j��|j�|�g|_|��|j�	�dS)N)
r�mapping�superr�__init__Zload_domains_from_mapZload_domains_from_options�short_names�load_short_names_from_mappingZset_initial_counts)�selfZconfigZopt_domains��	__class__��E/usr/lib/python3/dist-packages/sos/cleaner/parsers/hostname_parser.pyrs
zSoSHostnameParser.__init__cCs>|jj��D],}t|�d��dkr||jkr|j�|�qdS)aWhen we load the mapping file into the hostname map, we have to do
        some dancing to get those loaded properly into the "intermediate" dicts
        that the map uses to hold hosts and domains. Similarly, we need to also
        extract shortnames known to the map here.
        �.�N)rZdataset�keys�len�splitr�append)r
Zhnamer
r
rr	 s
z/SoSHostnameParser.load_short_names_from_mappingcCszd|krdS|�d�}t|�dkr4|j�|d�n|j�|�t|�dkrjd�|dd��}|j�|�|j�|�dS)z�Force add the domainname found in /sos_commands/host/hostname into
        the map. We have to do this here since the normal map prep approach
        from the parser would be ignored since the system's hostname is not
        guaranteed
        �	localhostNrrr����)rrrr�joinr�add)r
Zhostname_stringZdomainsZhigh_domainr
r
r�load_hostname_into_map,s
z(SoSHostnameParser.load_hostname_into_mapcCs||��}|D]j}|�d�sd|kr$q|��dd�}|D]<}t|�d��dkrh|j�|�|j�|�q8|j�|�q8qdS)a$Parse an archive's copy of /etc/hosts, which requires handling that
        is separate from the output of the `hostname` command. Just like
        load_hostname_into_map(), this has to be done explicitly and we
        cannot rely upon the more generic methods to do this reliably.
        �#rrNr)	�
splitlines�
startswithrrrrrZadd_regex_itemr)r
Zcontent�lines�lineZhostlnZhostr
r
r�load_hostname_from_etc_hosts@sz.SoSHostnameParser.load_hostname_from_etc_hosts)N)�__name__�
__module__�__qualname__�nameZmap_file_keyZregex_patternsrr	rr �
__classcell__r
r
rrrs�	rN)Zsos.cleaner.parsersrZ!sos.cleaner.mappings.hostname_maprrr
r
r
r�<module>s