PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
| Dir : /lib/python3.6/site-packages/bs4/builder/__pycache__/ |
| Server: Linux server1.ngambekcore.com 4.18.0-553.51.1.el8_10.x86_64 #1 SMP Wed Apr 30 04:00:07 EDT 2025 x86_64 IP: 159.198.77.92 |
| Dir : //lib/python3.6/site-packages/bs4/builder/__pycache__/__init__.cpython-36.pyc |
3
6]�/ � @ s, d dl mZ d dlZd dlZd dlmZmZmZmZ ddddgZ dZ
d Zd
ZdZ
dZd
ZG dd� de�Ze� ZG dd� de�ZG dd� de�ZG dd� de�Zdd� ZG dd� de�ZddlmZ ee� yddlmZ ee� W n ek
r� Y nX yddlmZ ee� W n ek
�r& Y nX dS )� )�defaultdictN)�CharsetMetaAttributeValue�ContentMetaAttributeValue�HTMLAwareEntitySubstitution�
whitespace_re�HTMLTreeBuilder�SAXTreeBuilder�TreeBuilder�TreeBuilderRegistryZfastZ
permissive�strictZxmlZhtmlZhtml5c @ s$ e Zd Zdd� Zdd� Zdd� ZdS )r
c C s t t�| _g | _d S )N)r �list�builders_for_feature�builders)�self� r �/usr/lib/python3.6/__init__.py�__init__ s
zTreeBuilderRegistry.__init__c C s4 x |j D ]}| j| jd|� qW | jjd|� dS )z8Register a treebuilder based on its advertised features.r N)�featuresr
�insertr )r Ztreebuilder_class�featurer r r �register$ s zTreeBuilderRegistry.registerc G s� t | j�dkrd S t |�dkr(| jd S t|�}|j� d }d }xVt |�dkr�|j� }| jj|g �}t |�dkrB|d kr�|}t|�}qB|jt|��}qBW |d kr�d S x|D ]}||kr�|S q�W d S )Nr ) �lenr r �reverse�popr
�get�set�intersection)r r Z
candidatesZ
candidate_setr Zwe_have_the_feature� candidater r r �lookup* s.
zTreeBuilderRegistry.lookupN)�__name__�
__module__�__qualname__r r r r r r r r
s c @ st e Zd ZdZdZg Zg ZdZdZe � Z
dZi Zdd� Z
dd� Zd d
� Zdd� Zdd
d�Zdd� Zdd� Zdd� ZdS )r z2Turn a document into a Beautiful Soup object tree.z[Unknown tree builder]FNc C s
d | _ d S )N)�soup)r r r r r f s zTreeBuilder.__init__c C s d S )Nr )r r r r �reseti s zTreeBuilder.resetc C s | j dkrdS || j kS )a� Might a tag with this name be an empty-element tag?
The final markup may or may not actually present this tag as
self-closing.
For instance: an HTMLBuilder does not consider a <p> tag to be
an empty-element tag (it's not in
HTMLBuilder.empty_element_tags). This means an empty <p> tag
will be presented as "<p></p>", not "<p />".
The default implementation has no opinion about which tags are
empty-element tags, so a tag will be presented as an
empty-element tag if and only if it has no contents.
"<foo></foo>" will become "<foo />", and "<foo>bar</foo>" will
be left alone.
NT)�empty_element_tags)r �tag_namer r r �can_be_empty_elementl s
z TreeBuilder.can_be_empty_elementc C s
t � �d S )N)�NotImplementedError)r �markupr r r �feed� s zTreeBuilder.feedc C s |d d dfS )NFr )r r( Zuser_specified_encodingZdocument_declared_encodingr r r �prepare_markup� s zTreeBuilder.prepare_markupc C s |S )a� Wrap an HTML fragment to make it look like a document.
Different parsers do this differently. For instance, lxml
introduces an empty <head> tag, and html5lib
doesn't. Abstracting this away lets us write simple tests
which run HTML fragments through the parser and compare the
results against other HTML fragments.
This method should not be used outside of tests.
r )r Zfragmentr r r �test_fragment_to_document� s z%TreeBuilder.test_fragment_to_documentc C s dS )NFr )r �tagr r r �set_up_substitutions� s z TreeBuilder.set_up_substitutionsc C s� |s|S | j r�| j jdg �}| j j|j� d�}xRt|j� �D ]B}||ksT|r<||kr<|| }t|t�rrtj|�}n|}|||<