• File: soupparser.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/site-packages/lxml/html/__pycache__/soupparser.cpython-37.pyc
  • Date Modified: 04/24/2023 6:38 PM
  • File size: 7.72 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

'Y'@sTdZdddgZddlZddlmZmZy0ddlmZmZm	Z	m
Z
mZmZm
Z
ee
fZWn8ek
rddlmZmZm	Z	m
Z
mZmZeZYnXdd	dZdd
dZdddZdd
ZedejjZGdddZddZddZyddlmZWn"ek
rddlmZYnXedjZye Wne!k
rFe"Z YnXddZ#dS)z5External interface to the BeautifulSoup HTML parser.

fromstringparseconvert_treeN)etreehtml)
BeautifulSoupTagCommentProcessingInstructionNavigableStringDeclarationDoctype)rrr	r
rrcKst|||f|S)aParse a string of HTML data into an Element tree using the
    BeautifulSoup parser.

    Returns the root ``<html>`` Element of the tree.

    You can pass a different BeautifulSoup parser through the
    `beautifulsoup` keyword, and a diffent Element factory function
    through the `makeelement` keyword.  By default, the standard
    ``BeautifulSoup`` class and the default factory of `lxml.html` are
    used.
    )_parse)data
beautifulsoupmakeelementbsargsrG/opt/alt/python37/lib64/python3.7/site-packages/lxml/html/soupparser.pyrscKs,t|dst|}t|||f|}t|S)aYParse a file into an ElemenTree using the BeautifulSoup parser.

    You can pass a different BeautifulSoup parser through the
    `beautifulsoup` keyword, and a diffent Element factory function
    through the `makeelement` keyword.  By default, the standard
    ``BeautifulSoup`` class and the default factory of `lxml.html` are
    used.
    read)hasattropenrrZElementTree)filerrrrootrrrr$s	
cCs.t||}|}x|D]}||qW|S)aConvert a BeautifulSoup tree to a list of Element trees.

    Returns a list instead of a single root Element to support
    HTML-like soup with more than one root element.

    You can pass a different Element factory through the `makeelement`
    keyword.
    )
_convert_treeZgetchildrenremove)beautiful_soup_treerrZchildrenchildrrrr3s
	

cKs|dkrt}t|dr&d|kr&d|d<t|dr@d|kr@d|d<||f|}t||}t|dkrx|djdkrx|dSd|_|S)	NZ
HTML_ENTITIESZconvertEntitiesrZDEFAULT_BUILDER_FEATURESZfeatureszhtml.parserr)rrrlentag)sourcerrrZtreerrrrrEs


rz`(?:\s|[<!])*DOCTYPE\s*HTML(?:\s+PUBLIC)?(?:\s+(\'[^\']*\'|"[^"]*"))?(?:\s+(\'[^\']*\'|"[^"]*"))?c@seZdZddZddZdS)
_PseudoTagcCsd|_g|_||_dS)Nr)nameattrscontents)selfr%rrr__init__`sz_PseudoTag.__init__cCs
|jS)N)r%__iter__)r&rrrr(esz_PseudoTag.__iter__N)__name__
__module____qualname__r'r(rrrrr"^sr"cCs|dkrtjj}d}}d}}xft|D]Z\}}t|trn|dkrH|}|}|dkr|jr|jdkr|}q*|dkr*t|tr*|}q*W|dkrg}}	|j	}
n2|j	d|}|j	||d}
|j	|dd}	|dk	r|

|}|
d||j	|
|dd|_	nt|
}t|}||}|}
x2t
|D]&}||}|dk	r2|
||}
q2W|}
x.|	D]&}||}|dk	rf|
||}
qfW|dk	ry|}Wntk
r|j}YnXt|}|sn>|\}}|j}|o|dd|_|o|dd|_|S)Nrr)rZhtml_parserr	enumerate
isinstancerr#lower_DECLARATION_OR_DOCTYPEr%indexr"_init_node_convertersreversedZaddpreviousZaddnextZoutput_readyAttributeErrorstring_parse_doctype_declarationgroupsZgetroottreedocinfoZ	public_idZ
system_url)rrZfirst_element_idxZlast_element_idxZ	html_rootZdeclarationieZpre_rootZ	post_rootrootsconvert_nodeZres_rootprevZ	convertedZdoctype_stringmatchZexternal_idZsys_urir8rrrrisd


&








rcsigfdd}fdddfdd	ddd	d
|ttfdd}|td
d}|tdd}|tfdd}S)Ncsfdd}|S)Ncs$xD]}||<|qW|S)N)append)handlert)
convertersordered_node_typestypesrradds
z5_init_node_converters.<locals>.converter.<locals>.addr)rDrE)rBrC)rDr	convertersz(_init_node_converters.<locals>.convertercs$xD]}t||r|SqWdS)N)r.)ZnoderA)rBrCrrfind_best_converters

z2_init_node_converters.<locals>.find_best_convertercsPyt|}Wn(tk
r8|}t|<YnX|dkrFdS|||S)N)typeKeyError)bs_nodeparentr@)rBrGrrr<sz+_init_node_converters.<locals>.convert_nodecSs\t|trFi}xH|D](\}}t|tr4d|}t|||<qWntdd|D}|S)N css|]\}}|t|fVqdS)N)unescape).0kvrrr	<genexpr>sz;_init_node_converters.<locals>.map_attrs.<locals>.<genexpr>)r.dictitemslistjoinrM)Zbs_attrsattribsrOrPrrr	map_attrss


z(_init_node_converters.<locals>.map_attrscSs:t|dkr|jpd||_n|djp*d||d_dS)Nrr,)rtexttail)rKrYrrrappend_textsz*_init_node_converters.<locals>.append_textc	s|j}|dk	r2|r|nd}tj||j|d}n|r>|ni}|j|d}xP|D]H}yt|}Wntk
r~YnX|dk	rV|||qV||qVW|S)N)Zattrib)r$rZ
SubElementr#rHrI)rJrKr$rVresrr@)r<rBrrWrrconvert_tags 

z*_init_node_converters.<locals>.convert_tagcSs t|}|dk	r|||S)N)rZHtmlCommentr?)rJrKr\rrrconvert_comments

z._init_node_converters.<locals>.convert_commentcSs>|dr|dd}tj|dd}|dk	r:|||S)N?r,rLr)endswithrr
splitr?)rJrKr\rrr
convert_pis

z)_init_node_converters.<locals>.convert_pics|dk	r|t|dS)N)rM)rJrK)r[rrconvert_textsz+_init_node_converters.<locals>.convert_text)N)rr"r	r
r)rrFr]r^rbrcr)r[r<rBrGrrWrCrr2s
r2)name2codepointz&(\w+);cCs|sdSdd}t||S)NrXcSs2ytt|dStk
r,|dSXdS)Nrr)unichrrdgrouprI)mrrrunescape_entity5sz!unescape.<locals>.unescape_entity)handle_entities)r5rhrrrrM1srM)NN)NN)N)$__doc____all__reZlxmlrrZbs4rrr	r
rrr
r0ImportErrorrrrrcompile
IGNORECASEr>r6r"rr2Z
html.entitiesrdZhtmlentitydefssubrire	NameErrorchrrMrrrr<module>s:
$ 




Uc