Sindbad~EG File Manager
�
(ٜgK: � � � d Z dZdgZddlmZ ddlZddlZddlmZm Z m
Z
mZmZ ddl
mZmZ ddlmZmZmZmZmZ d Z G d
� dee� Z G d� de� Zy)
zCUse the HTMLParser library to parse HTML files that aren't too bad.�MIT�HTMLParserTreeBuilder� )�
HTMLParserN)�CData�Comment�Declaration�Doctype�ProcessingInstruction)�EntitySubstitution�
UnicodeDammit)�DetectsXMLParsedAsHTML�ParserRejectedMarkup�HTML�HTMLTreeBuilder�STRICTzhtml.parserc �d � e Zd ZdZdZdZd� Zd� Zd� Zdd�Z dd�Z
d � Zd
� Zd� Z
d� Zd
� Zd� Zd� Zy)�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.
�ignore�replacec � � |j d| j � | _ t j | g|��i |�� g | _ | j
� y)a Constructor.
:param on_duplicate_attribute: A strategy for what to do if a
tag includes the same attribute more than once. Accepted
values are: REPLACE (replace earlier values with later
ones, the default), IGNORE (keep the earliest value
encountered), or a callable. A callable must take three
arguments: the dictionary of attributes already processed,
the name of the duplicate attribute, and the most recent value
encountered.
�on_duplicate_attributeN)�pop�REPLACEr r �__init__�already_closed_empty_element�_initialize_xml_detector)�self�args�kwargss �B/usr/local/lib/python3.12/site-packages/bs4/builder/_htmlparser.pyr z BeautifulSoupHTMLParser.__init__. sN � � '-�j�j�$�d�l�l�'
��#� ���D�2�4�2�6�2� -/��)��%�%�'� c � � t |� �)N)r )r �messages r �errorzBeautifulSoupHTMLParser.errorJ s � � #�7�+�+r! c �N � | j ||d�� }| j |� y)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�tags r �handle_startendtagz*BeautifulSoupHTMLParser.handle_startendtagZ s) � � �"�"�4��U�"�K�����4� r! c �� � i }|D ]Q \ }}|�d}||v r=| j }|| j k( rn&|d| j fv r|||<