HEX
Server: Apache
System: Linux vps.rockyroadprinting.net 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: rockyroadprintin (1011)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python2.7/site-packages/bs4/diagnose.pyc
�
�?J[c@sodZdZddlZddlmZddlmZddlZddlmZmZddlm	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZd�Zed	�Zd
efd��YZd�Zd
ZdZdd�Zdd�Zdd�Zdd�Zddd�Zedkrkeejj��ndS(s=Diagnostic functions, mainly for use when doing tech support.tMITi����N(tStringIO(t
HTMLParser(t
BeautifulSoupt__version__(tbuilder_registrycCsVdtGHdtjGHdddg}xK|D]C}x:tjD]}||jkr;Pq;q;W|j|�d|GHq+Wd|kr�|jd�y2dd	lm	}d
dj
tt|j
��GHWq�tk
r�}dGHq�Xnd|kr!ydd
l}d|jGHWq!tk
r}dGHq!Xnt|d�r?|j�}n�|jd�s]|jd�rod|GHdGHd
SyCtjj|�r�d|GHt|��}|j�}Wd
QXnWntk
r�nXHx�|D]�}d|GHt}	yt|d|�}
t}	Wn&tk
r'}d|GHtj�nX|	rEd|GH|
j�GHnddGHq�Wd
S(s/Diagnostic suite for isolating common problems.s'Diagnostic running on Beautiful Soup %ssPython version %sshtml.parserthtml5libtlxmls;I noticed that %s is not installed. Installing it may help.slxml-xmli����(tetreesFound lxml version %st.s.lxml is not installed or couldn't be imported.NsFound html5lib version %ss2html5lib is not installed or couldn't be imported.treadshttp:shttps:s<"%s" looks like a URL. Beautiful Soup is not an HTTP client.spYou need to use some other library to get the document behind the URL, and feed that document to Beautiful Soup.s7"%s" looks like a filename. Reading data from the file.s#Trying to parse your markup with %stfeaturess%s could not parse the markup.s#Here's what %s did with the markup:t-iP(RtsystversionRtbuildersRtremovetappendRRtjointmaptstrtLXML_VERSIONtImportErrorRthasattrR
t
startswithtostpathtexiststopent
ValueErrortFalseRtTruet	Exceptiont	tracebackt	print_exctprettify(tdatat
basic_parserstnametbuilderRteRtfptparsertsuccesstsoup((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pytdiagnosesd	



"		

	
		cKs[ddlm}xD|jt|�d||�D]$\}}d||j|jfGHq/WdS(s�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.
    i����(Rthtmls%s, %4s, %sN(RRt	iterparseRttagttext(R$R.tkwargsRteventtelement((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pyt
lxml_traceZs+tAnnouncingParsercBsheZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(s?Announces HTMLParser parse events, without doing anything else.cCs	|GHdS(N((tselfts((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pyt_pgscCs|jd|�dS(Ns%s START(R9(R7R&tattrs((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pythandle_starttagjscCs|jd|�dS(Ns%s END(R9(R7R&((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pyt
handle_endtagmscCs|jd|�dS(Ns%s DATA(R9(R7R$((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pythandle_datapscCs|jd|�dS(Ns
%s CHARREF(R9(R7R&((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pythandle_charrefsscCs|jd|�dS(Ns%s ENTITYREF(R9(R7R&((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pythandle_entityrefvscCs|jd|�dS(Ns
%s COMMENT(R9(R7R$((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pythandle_commentyscCs|jd|�dS(Ns%s DECL(R9(R7R$((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pythandle_decl|scCs|jd|�dS(Ns%s UNKNOWN-DECL(R9(R7R$((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pytunknown_declscCs|jd|�dS(Ns%s PI(R9(R7R$((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pyt	handle_pi�s(
t__name__t
__module__t__doc__R9R;R<R=R>R?R@RARBRC(((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pyR6ds									cCst�}|j|�dS(s�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.
    N(R6tfeed(R$R*((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pythtmlparser_trace�s	taeioutbcdfghjklmnpqrstvwxyzicCsSd}xFt|�D]8}|ddkr2t}nt}|tj|�7}qW|S(s#Generate a random word-like string.tii(tranget_consonantst_vowelstrandomtchoice(tlengthR8titt((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pytrword�s	icCsdjd�t|�D��S(s'Generate a random sentence-like string.t css'|]}ttjdd��VqdS(ii	N(RTROtrandint(t.0RR((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pys	<genexpr>�s(RRL(RQ((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pyt	rsentence�si�cCs�dddddddg}g}x�t|�D]�}tjdd	�}|dkrutj|�}|jd
|�q.|dkr�|jttjdd���q.|d
kr.tj|�}|jd|�q.q.Wddj|�dS(s+Randomly generate an invalid HTML document.tptdivtspanRRtbtscriptttableiis<%s>iiis</%s>s<html>s
s</html>(RLRORVRPRRXR(tnum_elementst	tag_namestelementsRRRPttag_name((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pytrdoc�s"i��c
CsSdtGHt|�}dt|�GHx�dddgddgD]�}t}y1tj�}t||�}tj�}t}Wn&tk
r�}d|GHtj	�nX|r=d|||fGHq=q=Wd	d
l
m}tj�}|j|�tj�}d||GHd	dl
}	|	j�}tj�}|j|�tj�}d
||GHdS(s.Very basic head-to-head performance benchmark.s1Comparative parser benchmark on Beautiful Soup %ss3Generated a large invalid HTML document (%d bytes).RR.Rshtml.parsers%s could not parse the markup.s"BS4+%s parsed the markup in %.2fs.i����(Rs$Raw lxml parsed the markup in %.2fs.Ns(Raw html5lib parsed the markup in %.2fs.(RRctlenRttimeRRR R!R"RRtHTMLRRtparse(
R_R$R*R+taR,R\R(RR((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pytbenchmark_parsers�s4	
	


RcCs�tj�}|j}t|�}tdtd|d|�}tjd|||�tj	|�}|j
d�|jdd�dS(Ntbs4R$R*sbs4.BeautifulSoup(data, parser)t
cumulatives
_html5lib|bs4i2(ttempfiletNamedTemporaryFileR&RctdictRjtcProfiletrunctxtpstatstStatst
sort_statstprint_stats(R_R*t
filehandletfilenameR$tvarststats((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pytprofile�s	
t__main__( RFt__license__RoRRRjRRtbs4.builderRRRqRORlReR!R
R-RR5R6RHRNRMRTRXRcRiRyRDtstdinR
(((s0/usr/lib/python2.7/site-packages/bs4/diagnose.pyt<module>s8	C
!