File: //usr/local/CyberCP/lib64/python3.10/site-packages/bs4/builder/__pycache__/__init__.cpython-310.pyc
o
�h�_ � @ sf d Z ddlmZ ddlZddlZddlZddlZddlmZm Z m
Z
mZmZm
Z
mZmZ g d�ZdZdZdZd Zd
ZdZG dd
� d
e�ZG dd� de�Ze� ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Zdd� Z G dd� de!�Z"ddl#m$Z$ e e$� zddl#m%Z% e e%� W n e&y� Y nw z
ddl#m'Z' e e'� W dS e&y� Y dS w ) �MIT� )�defaultdictN)�CharsetMetaAttributeValue�ContentMetaAttributeValue�RubyParenthesisString�RubyTextString�
Stylesheet�Script�TemplateString�nonwhitespace_re)�HTMLTreeBuilder�SAXTreeBuilder�TreeBuilder�TreeBuilderRegistry�fast�
permissive�strict�xml�html�html5c @ s e Zd ZdZdZdS )�XMLParsedAsHTMLWarningzWThe warning issued when an HTML parser is used to parse
XML that is not XHTML.
a� It looks like you're parsing an XML document using an HTML parser. If this really is an HTML document (maybe it's XHTML?), you can ignore or filter this warning. If it's XML, you should know that using an XML parser will be more reliable. To parse this document as XML, make sure you have the lxml package installed, and pass the keyword argument `features="xml"` into the BeautifulSoup constructor.N)�__name__�
__module__�__qualname__�__doc__�MESSAGE� r r �G/usr/local/CyberCP/lib/python3.10/site-packages/bs4/builder/__init__.pyr # s r c @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) r zYA way of looking up TreeBuilder subclasses by their name or by desired
features.
c C s t t�| _g | _d S �N)r �list�builders_for_feature�builders��selfr r r �__init__/ s
zTreeBuilderRegistry.__init__c C s0 |j D ]}| j| �d|� q| j�d|� dS )z�Register a treebuilder based on its advertised features.
:param treebuilder_class: A subclass of Treebuilder. its .features
attribute should list its features.
r N)�featuresr �insertr! )r# �treebuilder_class�featurer r r �register3 s
zTreeBuilderRegistry.registerc G s� t | j�dkr dS t |�dkr| jd S t|�}|�� d}d}t |�dkrO|�� }| j�|g �}t |�dkrI|du rB|}t|�}n|�t|��}t |�dks&|du rUdS |D ]
}||v ra| S qWdS )aj Look up a TreeBuilder subclass with the desired features.
:param features: A list of features to look for. If none are
provided, the most recently registered TreeBuilder subclass
will be used.
:return: A TreeBuilder subclass, or None if there's no
registered subclass with all the requested features.
r N) �lenr! r �reverse�popr �get�set�intersection)r# r% �
candidates�
candidate_setr( �we_have_the_feature� candidater r r �lookup= s4
���zTreeBuilderRegistry.lookupN)r r r r r$ r) r4 r r r r r * s
r c @ s� e Zd ZdZdZg Zg ZdZdZdZ e
e�Ze
� Zi Ze� ZdZeeeefdd�Zdd� Zd d
� Zdd� Zd
d� Z ddd�Zdd� Zdd� Zdd� ZdS )r z:Turn a textual document into a Beautiful Soup object tree.z[Unknown tree builder]FNc C sb d| _ || ju r| j}|| _|| ju r| j}|| _|| jkr!| j}|| _|| jkr,| j}|| _ dS )a� Constructor.
:param multi_valued_attributes: If this is set to None, the
TreeBuilder will not turn any values for attributes like
'class' into lists. Setting this to a dictionary will
customize this behavior; look at DEFAULT_CDATA_LIST_ATTRIBUTES
for an example.
Internally, these are called "CDATA list attributes", but that
probably doesn't make sense to an end-user, so the argument name
is `multi_valued_attributes`.
:param preserve_whitespace_tags: A list of tags to treat
the way <pre> tags are treated in HTML. Tags in this list
are immune from pretty-printing; their contents will always be
output as-is.
:param string_containers: A dictionary mapping tag names to
the classes that should be instantiated to contain the textual
contents of those tags. The default is to use NavigableString
for every tag, no matter what the name. You can override the
default by changing DEFAULT_STRING_CONTAINERS.
:param store_line_numbers: If the parser keeps track of the
line numbers and positions of the original markup, that
information will, by default, be stored in each corresponding
`Tag` object. You can turn this off by passing
store_line_numbers=False. If the parser you're using doesn't
keep track of this information, then setting store_line_numbers=True
will do nothing.
N)
�soup�USE_DEFAULT�DEFAULT_CDATA_LIST_ATTRIBUTES�cdata_list_attributes� DEFAULT_PRESERVE_WHITESPACE_TAGS�preserve_whitespace_tags�TRACKS_LINE_NUMBERS�store_line_numbers�DEFAULT_STRING_CONTAINERS�string_containers)r# �multi_valued_attributesr: r<