File: //lib/python3/dist-packages/bs4/builder/__pycache__/_htmlparser.cpython-38.pyc
U
t�^sA �
@ s� d Z dZdgZddlmZ zddlmZ W n2 ek
r\ Z zG dd� de�ZW 5 dZ[X Y nX ddl Z ddl
Z
e jdd � \ZZ
Zed ko�e
d
ko�ed kZed ko�e
d kZed ko�e
dkZddlmZmZmZmZmZ dd
lmZmZ ddlmZmZmZ dZG dd� de�Z G dd� de�Z!ed k�r�e
d
k�r�e�s�ddl"Z"e"�#d�Z$e$e!_$e"�#de"j%�Z&e&e _&ddlm'Z'm(Z( dd� Z)dd� Z*e)e _)e*e _*dZdS )zCUse the HTMLParser library to parse HTML files that aren't too bad.ZMIT�HTMLParserTreeBuilder� )�
HTMLParser)�HTMLParseErrorc @ s e Zd ZdS )r N)�__name__�
__module__�__qualname__� r r �9/usr/lib/python3/dist-packages/bs4/builder/_htmlparser.pyr s r N� � � )�CData�Comment�Declaration�Doctype�ProcessingInstruction)�EntitySubstitution�
UnicodeDammit)�HTML�HTMLTreeBuilder�STRICTzhtml.parserc @ st e Zd ZdZdd� Zdd� Zdd� Zdd d
�Zddd�Zd
d� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� ZdS )�BeautifulSoupHTMLParserz�A subclass of the Python standard library's HTMLParser class, which
listens for HTMLParser events and translates them into calls
to Beautiful Soup's tree construction API.
c O s t j| f|�|� g | _d S )N)r �__init__�already_closed_empty_element)�self�args�kwargsr r r r = s z BeautifulSoupHTMLParser.__init__c C s t �|� dS )a� In Python 3, HTMLParser subclasses must implement error(), although
this requirement doesn't appear to be documented.
In Python 2, HTMLParser implements error() by raising an exception,
which we don't want to do.
In any event, this method is called only on very strange
markup and our best strategy is to pretend it didn't happen
and keep going.
N)�warnings�warn)r �msgr r r �errorI s zBeautifulSoupHTMLParser.errorc C s | j ||dd�}| �|� dS )z�Handle an incoming empty-element tag.
This is only called when the markup looks like <tag/>.
:param name: Name of the tag.
:param attrs: Dictionary of the tag's attributes.
F)�handle_empty_elementN)�handle_starttag�
handle_endtag)r �name�attrs�tagr r r �handle_startendtagV s z*BeautifulSoupHTMLParser.handle_startendtagTc C sz i }|D ] \}}|dkrd}|||<