3
Ü““iM ã @ s4 d dl Z d dlmZ d dlmZ G dd„ deƒZdS )é N)ÚSoSCleanerParser)ÚSoSHostnameMapc s6 e Zd ZdZdZdgZg f‡ fdd„ Zdd„ Z‡ ZS )ÚSoSHostnameParserzHostname ParserZhostname_mapz5(((\b|_)[a-zA-Z0-9-\.]{1,200}\.[a-zA-Z]{1,63}(\b|_)))c s t |ƒ| _tƒ j||ƒ d S )N)r ÚmappingÚsuperÚ__init__)ÚselfÚconfigZworkdirZskip_cleaning_files)Ú __class__© ú%/usr/lib/python3.6/hostname_parser.pyr s
zSoSHostnameParser.__init__c C sf d}x&| j D ]}tj||tjƒr||fS qW | j|ƒ\}}||7 }| jr^| j|ƒ\}}||7 }||fS )a This will be called for every line in every file we process, so that
every parser has a chance to scrub everything.
We are overriding parent method since we need to swap ordering of
_parse_line_with_compiled_regexes and _parse_line calls.
r )Zskip_line_patternsÚreÚmatchÚIZ_parse_lineZcompile_regexesZ!_parse_line_with_compiled_regexes)r ÚlineÚcountZskip_patternÚ_countZ_rcountr r r Ú
parse_line s zSoSHostnameParser.parse_line) Ú__name__Ú
__module__Ú__qualname__ÚnameZmap_file_keyZregex_patternsr r Ú
__classcell__r r )r
r r s
r )r
Zsos.cleaner.parsersr Z!sos.cleaner.mappings.hostname_mapr r r r r r Ú