← Back
Editing: _htmlparser.cpython-311.pyc
� S�c�5 � � � d Z dZdgZddlmZ ddlZddlZddlmZm Z m Z mZmZ ddl mZmZ ddlmZmZmZmZ d Z G d � dee� � Z G d� de� � ZdS ) zCUse the HTMLParser library to parse HTML files that aren't too bad.�MIT�HTMLParserTreeBuilder� )� HTMLParserN)�CData�Comment�Declaration�Doctype�ProcessingInstruction)�EntitySubstitution� UnicodeDammit)�DetectsXMLParsedAsHTML�HTML�HTMLTreeBuilder�STRICTzhtml.parserc �` � e Zd ZdZdZdZd� Zd� Zdd�Zdd�Z d � Z d � Zd� Zd� Z d � Zd� Zd� 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. �ignore�replacec � � |� d| j � � | _ t j | g|�R i |�� g | _ | � � � dS )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 �9/usr/lib/python3/dist-packages/bs4/builder/_htmlparser.pyr z BeautifulSoupHTMLParser.__init__- sf � � '-�j�j�$�d�l�' � ' ��#� ��D�2�4�2�2�2�6�2�2�2� -/��)��%�%�'�'�'�'�'� c �` � | � ||d�� � }| � |� � 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�tags r �handle_startendtagz*BeautifulSoupHTMLParser.handle_startendtagI s8 � � �"�"�4��U�"�K�K�����4� � � � � r Tc � � i }|D ]F\ }}|�d}||v r2| j }|| j k rn$|d| j fv r|||<