Files
old-saburly-wagtail-web/env/lib/python3.10/site-packages/bs4/__pycache__/diagnose.cpython-310.pyc

88 lines
7.8 KiB
Plaintext
Raw Normal View History

2024-08-27 20:33:44 +02:00
o
<00><><EFBFBD>f<00>@sdZdZddlZddlmZddlmZddlZddlmZm Z ddl
m Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZdd <09>Zd#d d <0C>ZGd d<0E>de<06>Zdd<10>ZdZdZd$dd<15>Zd%dd<18>Zd&dd<1B>Zd'dd<1E>Zd(d d!<21>Zed"kr<>eej<1F> <20><00>dSdS))z=Diagnostic functions, mainly for use when doing tech support.<2E>MIT<49>N)<01>BytesIO)<01>
HTMLParser)<02> BeautifulSoup<75> __version__)<01>builder_registryc
Cs<>tdt<00>tdtj<00>gd<03>}|D]}tjD] }||jvr!n q|<01>|<02>td|<00>qd|vrc|<01>d<06>zddl m
}td d
<EFBFBD> t t |j<0E><02><00>Wntyb}z
td <0B>WYd }~nd }~wwd |vr<>z dd l}td|j<00>Wnty<>}z
td<0F>WYd }~nd }~wwt|d<10>r<>|<00><12>}|D]C}td|<00>d}z
t||d<13>} d}Wnty<>}ztd|<00>t<15><16>WYd }~nd }~ww|r<>td|<00>t| <09><17><00>td<17>q<>d S)z<>Diagnostic suite for isolating common problems.
:param data: A string containing markup that needs to be explained.
:return: None; diagnostics are printed to standard output.
z'Diagnostic running on Beautiful Soup %szPython version %s)<03> html.parser<65>html5lib<69>lxmlz;I noticed that %s is not installed. Installing it may help.r
zlxml-xmlr<00><01>etreezFound lxml version %s<>.z.lxml is not installed or couldn't be imported.Nr zFound html5lib version %sz2html5lib is not installed or couldn't be imported.<2E>readz#Trying to parse your markup with %sF)<01>featuresT<73>%s could not parse the markup.z#Here's what %s did with the markup:zP--------------------------------------------------------------------------------)<18>printr<00>sys<79>versionr<00>buildersr<00>remove<76>appendr
r <00>join<69>map<61>str<74> LXML_VERSION<4F> ImportErrorr <00>hasattrrr<00> Exception<6F> traceback<63> print_exc<78>prettify)
<EFBFBD>data<74> basic_parsers<72>name<6D>builderr <00>er <00>parser<65>success<73>soup<75>r)<00>N/home/amir/Desktop/saburlyweb/env/lib/python3.10/site-packages/bs4/diagnose.py<70>diagnosesl 

<02>
<02><04><02>
 <10><08><02><10><08><02>
   <08><02>  
<04>r+TcKspddlm}|<02>dd<04>}t|t<04>r|<00>d<05>}t|<00>}|j|f||d<06>|<02><01>D]\}}td||j |j
f<00>q&dS) a<>Print out the lxml events that occur during parsing.
This lets you see how lxml parses a document when no Beautiful
Soup code is running. You can use this to determine whether
an lxml-specific problem is in Beautiful Soup's lxml tree builders
or in lxml itself.
:param data: Some markup.
:param html: If True, markup will be parsed with lxml's HTML parser.
if False, lxml's XML parser will be used.
rr <00>recoverT<72>utf8)<02>htmlr,z %s, %4s, %sN) r
r <00>pop<6F>
isinstancer<00>encoder<00> iterparser<00>tag<61>text)r!r.<00>kwargsr r,<00>reader<65>event<6E>elementr)r)r*<00>
lxml_traceNs 

<02><04><0E><04>r9c@s`eZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Z dd<0F>Z
dd<11>Z dd<13>Z dd<15>Z dS)<17>AnnouncingParserz<72>Subclass of HTMLParser that announces parse events, without doing
anything else.
You can use this to get a picture of how html.parser sees a given
document. The easiest way to do this is to call `htmlparser_trace`.
cCs t|<01>dS)N)r)<02>self<6C>sr)r)r*<00>_pls zAnnouncingParser._pcC<00>|<00>d|<00>dS)Nz%s START<52>r=)r;r#<00>attrsr)r)r*<00>handle_starttago<00>z AnnouncingParser.handle_starttagcCr>)Nz%s ENDr?<00>r;r#r)r)r*<00> handle_endtagrrBzAnnouncingParser.handle_endtagcCr>)Nz%s DATAr?<00>r;r!r)r)r*<00> handle_dataurBzAnnouncingParser.handle_datacCr>)Nz
%s CHARREFr?rCr)r)r*<00>handle_charrefxrBzAnnouncingParser.handle_charrefcCr>)Nz %s ENTITYREFr?rCr)r)r*<00>handle_entityref{rBz!AnnouncingParser.handle_entityrefcCr>)Nz
%s COMMENTr?rEr)r)r*<00>handle_comment~rBzAnnouncingParser.handle_commentcCr>)Nz%s DECLr?rEr)r)r*<00> handle_decl<63>rBzAnnouncingParser.handle_declcCr>)Nz%s UNKNOWN-DECLr?rEr)r)r*<00> unknown_decl<63>rBzAnnouncingParser.unknown_declcCr>)Nz%s PIr?rEr)r)r*<00> handle_pi<70>rBzAnnouncingParser.handle_piN)<0E>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r=rArDrFrGrHrIrJrKrLr)r)r)r*r:ds r:cCst<00>}|<01>|<00>dS)z<>Print out the HTMLParser events that occur during parsing.
This lets you see how HTMLParser parses a document when no
Beautiful Soup code is running.
:param data: Some markup.
N)r:<00>feed)r!r&r)r)r*<00>htmlparser_trace<63>srR<00>aeiou<6F>bcdfghjklmnpqrstvwxyz<79>cCs:d}t|<00>D]}|ddkrt}nt}|t<03>|<03>7}q|S)z#Generate a random word-like string.<2E><00>r)<05>range<67> _consonants<74>_vowels<6C>random<6F>choice)<04>lengthr<<00>i<>tr)r)r*<00>rword<72>s  r`<00>cCsd<01>dd<03>t|<00>D<00><01>S)z'Generate a random sentence-like string.<2E> css <00>|] }tt<01>dd<01><02>VqdS)ra<00> N)r`r[<00>randint)<02>.0r^r)r)r*<00> <genexpr><3E>s<02>zrsentence.<locals>.<genexpr>)rrX)r]r)r)r*<00> rsentence<63>srg<00><>cCs<>gd<01>}g}t|<00>D]9}t<01>dd<03>}|dkr#t<01>|<01>}|<02>d|<00>q
|dkr3|<02>tt<01>dd<06><02><01>q
|dkrCt<01>|<01>}|<02>d|<00>q
d d
<EFBFBD>|<02>d S) z+Randomly generate an invalid HTML document.)<07>p<>div<69>spanr^<00>b<>script<70>tabler<00>z<%s><3E>rarWz</%s>z<html><3E>
z</html>)rXr[rdr\rrgr)<06> num_elements<74> tag_names<65>elementsr^r\<00>tag_namer)r)r*<00>rdoc<6F>s  

<02>rvc
Cs&tdt<00>t|<00>}tdt|<01><00>dddgddfD]>}d}zt<04><04>}t||<02>}t<04><04>}d}WntyK}ztd |<00>t<07><08>WYd
}~nd
}~ww|rXtd |||f<00>qd d l m
}t<04><04>}|<08> |<01>t<04><04>}td||<00>d d
l } | <09> <0A>}t<04><04>}|<02>|<01>t<04><04>}td||<00>d
S)z.Very basic head-to-head performance benchmark.z1Comparative parser benchmark on Beautiful Soup %sz3Generated a large invalid HTML document (%d bytes).r
r.r rFTrNz"BS4+%s parsed the markup in %.2fs.rr z$Raw lxml parsed the markup in %.2fs.z(Raw html5lib parsed the markup in %.2fs.)rrrv<00>len<65>timerrrrr
r <00>HTMLr r<00>parse)
rrr!r&r'<00>ar(rlr%r r r)r)r*<00>benchmark_parsers<72>s: 
 <08><02><02> 

r}r
cCsXt<00><01>}|j}t|<00>}tt||d<01>}t<06>d|||<03>t<08> |<03>}|<06>
d<03>|<06> dd<05>dS)z7Use Python's profiler on a randomly generated document.)<03>bs4r!r&zbs4.BeautifulSoup(data, parser)<29>
cumulativez _html5lib|bs4<73>2N) <0C>tempfile<6C>NamedTemporaryFiler#rv<00>dictr~<00>cProfile<6C>runctx<74>pstats<74>Stats<74>
sort_stats<EFBFBD> print_stats)rrr&<00>
filehandle<EFBFBD>filenamer!<00>vars<72>statsr)r)r*<00>profile<6C>s

r<><00>__main__)T)rU)ra)rh)rw)rwr
)!rP<00> __license__r<5F><00>ior<00> html.parserrr~rr<00> bs4.builderr<00>osr<73>r[r<>ryrrr+r9r:rRrZrYr`rgrvr}r<>rM<00>stdinrr)r)r)r*<00><module>s<   
8& 



<04>