Your IP : 216.73.217.17


Current Path : /usr/lib/python2.7/site-packages/pyzor/
Upload File :
Current File : //usr/lib/python2.7/site-packages/pyzor/digest.pyc

�
�}Iec@s dZddlmZddlZddlZddlZddlZyddlZWn ek
rxddl	j
ZnXddgZejZ
ee
d�j��Zejdd	kr�ejd
�ej�e_ndejfd��YZd
efd��YZdefd��YZdS(sHandle digesting the messages.i����(tprint_functionNiii<tiitutf8tHTMLStrippercBs2eZdZd�Zd�Zd�Zd�ZRS(sStrip all tags from the HTML.cCs0tjj|�|j�||_t|_dS(N(t
HTMLParsert__init__tresett	collectortTruetcollect(tselfR((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyRs
	cCs2|j�}|r.|jr.|jj|�ndS(sKeep track of the data.N(tstripR	Rtappend(R
tdata((s0/usr/lib/python2.7/site-packages/pyzor/digest.pythandle_data"scCs8tjj|||�|j�dkr4t|_ndS(Ntscripttstyle(sscriptsstyle(Rthandle_starttagtlowertFalseR	(R
ttagtattrs((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyR(scCs5tjj||�|j�dkr1t|_ndS(NRR(sscriptsstyle(Rt
handle_endtagRRR	(R
R((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyR-s(t__name__t
__module__t__doc__RRRR(((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyRs
			tDataDigestercBs�eZdZddgZdZdZejd�Zejdej	�Z
ejd�Zejd�Zd	Z
dd
�Zd�Zd�Zd
�Zed��Zed��Zed��Zed��ZRS(sThe major workhouse class.tvaluetdigestiis\S+@\S+s
[a-z]+:\S+s\S{10,}s\sRcCs|dkrt}nd|_t�|_g}x�|j|�D]r}xi|j�D][}|j|�}|j|�rSy|j	|j
dd��Wq�tk
r�qSq�XqSqSWq@Wt|�|j
kr�|j|�n|j||�|jj�|_t|j�tkst�dS(NRtignore(tNonetdigest_specRtHASHRtdigest_payloadst
splitlinest	normalizetshould_handle_lineRtencodetUnicodeErrortlentatomic_num_linest
handle_atomict
handle_piecedt	hexdigestt	HASH_SIZEtAssertionError(R
tmsgtspectlinestpayloadtlinetnorm((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyRPs$		
cCs"x|D]}|j|�qWdS(sWe digest everything.N(thandle_line(R
R0R2((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyR)js
cCsyxr|D]j\}}x[t|�D]M}y&|t|t|�d�|}Wntk
r_q X|j|�q WqWdS(s#Digest stuff according to the spec.idN(trangetintR't
IndexErrorR4(R
R0R/toffsettlengthtiR2((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyR*os&
cCs|jj|j��dS(N(Rtupdatetrstrip(R
R2((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyR4zscCss|jdd�}|j}|jj||�}|jj||�}|jj||�}|jjd|�j�S(NtR(treplacetunwanted_txt_repltlongstr_ptrntsubt
email_ptrnturl_ptrntws_ptrnR(tclststrepl((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyR#}s	cCsMg}t|�}y|j|�Wnttjfk
r?nXdj|�S(Nt (RtfeedtUnicodeDecodeErrorRtHTMLParseErrortjoin(RFR
tstripper((s0/usr/lib/python2.7/site-packages/pyzor/digest.pytnormalize_html_part�scCst|�o|jt|�kS(N(R'tmin_line_length(RERF((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyR$�sccsGx@|j�D]2}|j�dkr%|jdt�}|j�}|r^|jdd�}nd}|ssd}n'|j�jdd�dkr�d
}ny|j||�}WnGtt	t
fk
r�y|jdd�}Wq�t	k
r�q
q�XnX|j�dkr|j|�Vq?|Vq
|j
�r4q
|j�Vq
WdS(NttexttdecodeR=RRtasciit_t-squopri-codectquoprisquoted-printabletquotedprintabletstrictthtml(squopri-codecsquoprisquoted-printablesquotedprintable(twalktget_content_maintypetget_payloadRtget_content_charsetR>RRQtLookupErrorR&R-tget_content_subtypeRNtis_multipart(RER.tpartR1tcharsetterrors((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyR!�s2			
N(RRRt	__slots__ROR(tretcompileRBt
IGNORECASERCR@RDR?RRR)R*R4tclassmethodR#tstaticmethodRNR$R!(((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyR3s"			tPrintingDataDigestercBseZdZd�ZRS(s6Extends DataDigester: prints out what we're digesting.cCs-t|jd��tt|�j|�dS(NR(tprintRQtsuperRiR4(R
R2((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyR4�s(RRRR4(((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyRi�s(ii(i<i(Rt
__future__RRdtsystcodecsthashlibRtImportErrorthtml.parsertparserRtsha1R R'R+R,tversion_infot	getwritertstdoutRtobjectRRi(((s0/usr/lib/python2.7/site-packages/pyzor/digest.pyt<module>s"
	�