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/dammit.pyo
�
o�\[c@sOdZdZddlZddlmZddlZddlZddlZdZ	yddl
Z
d�ZWnGek
r�yddl
Z
d�ZWq�ek
r�d�Zq�XnXyddlZWnek
r�nXejdj�ej�Zejd	j�ej�Zd
efd��YZddd
��YZddd��YZdS(sBBeautiful Soup bonus library: Unicode, Dammit

This library converts a bytestream to Unicode through any means
necessary. It is heavily based on code from Mark Pilgrim's Universal
Feed Parser. It works best on XML and HTML, but it does not rewrite the
XML or HTML to reflect a new encoding; that's the tree builder's job.
tMITi����N(tcodepoint2namecCstj|�dS(Ntencoding(tcchardettdetect(ts((s./usr/lib/python2.7/site-packages/bs4/dammit.pytchardet_dammitscCstj|�dS(NR(tchardetR(R((s./usr/lib/python2.7/site-packages/bs4/dammit.pyR!scCsdS(N(tNone(R((s./usr/lib/python2.7/site-packages/bs4/dammit.pyR'ss!^<\?.*encoding=['"](.*?)['"].*\?>s0<\s*meta[^>]+charset\s*=\s*["']?([^>]*?)[ /;'">]tEntitySubstitutioncBs�eZdZd�Ze�\ZZZidd6dd6dd6dd	6d
d6Zej	d�Z
ej	d
�Zed��Z
ed��Zed��Zeed��Zeed��Zed��ZRS(sASubstitute XML or HTML entities for the corresponding characters.cCs�i}i}g}x\ttj��D]H\}}t|�}|dkrc|j|�|||<n|||<q%Wddj|�}||tj|�fS(Ni"s[%s]t(tlistRtitemstunichrtappendtjointretcompile(tlookuptreverse_lookuptcharacters_for_ret	codepointtnamet	charactert
re_definition((s./usr/lib/python2.7/site-packages/bs4/dammit.pyt_populate_class_variables9s

tapost'tquott"tampt&tltt<tgtt>s&([<>]|&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;))s([<>&])cCs#|jj|jd��}d|S(Nis&%s;(tCHARACTER_TO_HTML_ENTITYtgettgroup(tclstmatchobjtentity((s./usr/lib/python2.7/site-packages/bs4/dammit.pyt_substitute_html_entityZscCs|j|jd�}d|S(smUsed with a regular expression to substitute the
        appropriate XML entity for an XML special character.is&%s;(tCHARACTER_TO_XML_ENTITYR&(R'R(R)((s./usr/lib/python2.7/site-packages/bs4/dammit.pyt_substitute_xml_entity_scCsNd}d|krBd|kr9d}|jd|�}qBd}n|||S(s*Make a value into a quoted XML attribute, possibly escaping it.

         Most strings will be quoted using double quotes.

          Bob's Bar -> "Bob's Bar"

         If a string contains double quotes, it will be quoted using
         single quotes.

          Welcome to "my bar" -> 'Welcome to "my bar"'

         If a string contains both single and double quotes, the
         double quotes will be escaped, and the string will be quoted
         using double quotes.

          Welcome to "Bob's Bar" -> "Welcome to &quot;Bob's bar&quot;
        RRs&quot;(treplace(tselftvaluet
quote_withtreplace_with((s./usr/lib/python2.7/site-packages/bs4/dammit.pytquoted_attribute_valuefs	cCs4|jj|j|�}|r0|j|�}n|S(sSubstitute XML entities for special XML characters.

        :param value: A string to be substituted. The less-than sign
          will become &lt;, the greater-than sign will become &gt;,
          and any ampersands will become &amp;. If you want ampersands
          that appear to be part of an entity definition to be left
          alone, use substitute_xml_containing_entities() instead.

        :param make_quoted_attribute: If True, then the string will be
         quoted, as befits an attribute value.
        (tAMPERSAND_OR_BRACKETtsubR,R2(R'R/tmake_quoted_attribute((s./usr/lib/python2.7/site-packages/bs4/dammit.pytsubstitute_xml�s
	cCs4|jj|j|�}|r0|j|�}n|S(s�Substitute XML entities for special XML characters.

        :param value: A string to be substituted. The less-than sign will
          become &lt;, the greater-than sign will become &gt;, and any
          ampersands that are not part of an entity defition will
          become &amp;.

        :param make_quoted_attribute: If True, then the string will be
         quoted, as befits an attribute value.
        (tBARE_AMPERSAND_OR_BRACKETR4R,R2(R'R/R5((s./usr/lib/python2.7/site-packages/bs4/dammit.pyt"substitute_xml_containing_entities�s
	cCs|jj|j|�S(s�Replace certain Unicode characters with named HTML entities.

        This differs from data.encode(encoding, 'xmlcharrefreplace')
        in that the goal is to make the result more readable (to those
        with ASCII displays) rather than to recover from
        errors. There's absolutely nothing wrong with a UTF-8 string
        containg a LATIN SMALL LETTER E WITH ACUTE, but replacing that
        character with "&eacute;" will make it more readable to some
        people.
        (tCHARACTER_TO_HTML_ENTITY_RER4R*(R'R((s./usr/lib/python2.7/site-packages/bs4/dammit.pytsubstitute_html�s	(t__name__t
__module__t__doc__RR$tHTML_ENTITY_TO_CHARACTERR9R+RRR7R3tclassmethodR*R,R2tFalseR6R8R:(((s./usr/lib/python2.7/site-packages/bs4/dammit.pyR	5s&	
%tEncodingDetectorcBs\eZdZdedd�Zd�Zed��Ze	d��Z
e	eed��ZRS(s^Suggests a number of possible encodings for a bytestring.

    Order of precedence:

    1. Encodings you specifically tell EncodingDetector to try first
    (the override_encodings argument to the constructor).

    2. An encoding declared within the bytestring itself, either in an
    XML declaration (if the bytestring is to be interpreted as an XML
    document), or in a <meta> tag (if the bytestring is to be
    interpreted as an HTML document.)

    3. An encoding detected through textual analysis by chardet,
    cchardet, or a similar external library.

    4. UTF-8.

    5. Windows-1252.
    cCs}|p	g|_|pg}tg|D]}|j�^q%�|_d|_||_d|_|j|�\|_	|_
dS(N(toverride_encodingstsettlowertexclude_encodingsRtchardet_encodingtis_htmltdeclared_encodingtstrip_byte_order_marktmarkuptsniffed_encoding(R.RJRBRGREtx((s./usr/lib/python2.7/site-packages/bs4/dammit.pyt__init__�s(			cCsO|dk	rK|j�}||jkr+tS||krK|j|�tSntS(N(RRDRER@taddtTrue(R.Rttried((s./usr/lib/python2.7/site-packages/bs4/dammit.pyt_usable�s
ccst�}x+|jD] }|j||�r|VqqW|j|j|�rW|jVn|jdkr�|j|j|j�|_n|j|j|�r�|jVn|j	dkr�t
|j�|_	n|j|j	|�r�|j	Vnx(dD] }|j||�r�|Vq�q�WdS(s<Yield a number of encodings that might work for this markup.sutf-8swindows-1252N(sutf-8swindows-1252(RCRBRQRKRHRtfind_declared_encodingRJRGRFR(R.RPte((s./usr/lib/python2.7/site-packages/bs4/dammit.pyt	encodings�s$	
cCs"d}t|t�r||fSt|�dkrg|d dkrg|dd!dkrgd}|d}n�t|�dkr�|d dkr�|dd!dkr�d}|d}ni|d d	kr�d
}|d}nF|d dkr�d}|d}n#|d d
krd}|d}n||fS(sMIf a byte-order mark is present, strip it and return the encoding it implies.iis��ssutf-16bes��sutf-16leissutf-8s��sutf-32bes��sutf-32leN(Rt
isinstancetunicodetlen(R'tdataR((s./usr/lib/python2.7/site-packages/bs4/dammit.pyRIs*
"
"



cCs�|rt|�}}n%d}tdtt|�d��}d}tj|d|�}|r~|r~tj|d|�}n|dk	r�|j�djdd�}n|r�|j	�SdS(	s�Given a document, tries to find its declared encoding.

        An XML encoding is declared at the beginning of the document.

        An HTML encoding is declared in a <meta> tag, hopefully near the
        beginning of the document.
        iig�������?tendpositasciiR-N(
RWtmaxtintRtxml_encoding_retsearchthtml_meta_retgroupstdecodeRD(R'RJRGtsearch_entire_documentt
xml_endposthtml_endposRHtdeclared_encoding_match((s./usr/lib/python2.7/site-packages/bs4/dammit.pyRR+s	

N(R;R<R=RR@RMRQtpropertyRTR?RIRR(((s./usr/lib/python2.7/site-packages/bs4/dammit.pyRA�s	
!t
UnicodeDammitcBs�eZdZidd6dd6ZdddgZgdegd�Zd	�Zd
d�Z	d
d�Z
ed
��Zd�Z
d�Zi dd6dd6dd6dd6dd6d	d 6d
d#6dd&6dd)6d
d,6dd/6dd26dd56d6d76dd:6d6d;6d6d<6dd?6ddB6ddE6ddH6ddK6ddN6ddQ6ddT6ddW6ddZ6dd]6dd`6d6da6ddd6ddg6Zi�dhd6dd6did6djd6dkd6dld 6dmd#6dnd&6dod)6dpd,6dqd/6drd26dsd56d6d76dtd:6d6d;6d6d<6dud?6dudB6dvdE6dvdH6dwdK6dxdN6dydQ6dzdT6d{dW6d|dZ6d}d]6d~d`6d6da6ddd6d�dg6dd�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6dqd�6d�d�6dfd�6d�d�6d�d�6d�d�6dd�6d�d�6dxd�6d�d�6d�d�6d�d�6d�d�6d d�6d�d�6d�d�6dwd�6did�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d6d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6dwd�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d6d�d6d�d6d�d6d�d6dd6d�d6dd6Zizd	d
6dd6d
d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6dUdV6dWdX6dYdZ6d[d\6d]d^6d_d`6dadb6dcdd6dedf6dgdh6didj6dkdl6dmdn6dodp6dqdr6dsdt6dudv6dwdx6dydz6d{d|6d}d~6dd�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6Zd!d"d#gZed�d�ZeddZeddd��ZRS($s�A class for detecting the encoding of a *ML document and
    converting it to a Unicode string. If the source encoding is
    windows-1252, can replace MS smart quotes with their HTML or XML
    equivalents.s	mac-romant	macintoshs	shift-jissx-sjisswindows-1252s
iso-8859-1s
iso-8859-2cCsn||_g|_t|_||_tjt�|_t	||||�|_
t|t�si|dkr�||_
t|�|_d|_dS|j
j
|_
d}x?|j
jD]1}|j
j
}|j|�}|dk	r�Pq�q�W|sOxa|j
jD]P}|dkr|j|d�}n|dk	r�|jjd�t|_Pq�q�Wn||_|sjd|_ndS(NR
RZR-sSSome characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.(tsmart_quotes_tottried_encodingsR@tcontains_replacement_charactersRGtloggingt	getLoggerR;tlogRAtdetectorRURVRJtunicode_markupRtoriginal_encodingRTt
_convert_fromtwarningRO(R.RJRBRiRGREtuR((s./usr/lib/python2.7/site-packages/bs4/dammit.pyRMXs>									cCs�|jd�}|jdkr9|jj|�j�}n�|jj|�}t|�tkr�|jdkr�dj�|dj�dj�}q�dj�|dj�dj�}n|j�}|S(s[Changes a MS smart quote character to an XML or HTML
        entity, or an ASCII character.iRZtxmls&#xt;Ri(R&RitMS_CHARS_TO_ASCIIR%tencodetMS_CHARSttypettuple(R.tmatchtorigR4((s./usr/lib/python2.7/site-packages/bs4/dammit.pyt_sub_ms_char�s''tstrictcCs�|j|�}|s+||f|jkr/dS|jj||f�|j}|jdk	r�||jkr�d}tj|�}|j	|j
|�}ny+|j|||�}||_||_Wnt
k
r�}dSX|jS(Ns([�-�])(t
find_codecRjRRRJRitENCODINGS_WITH_SMART_QUOTESRRR4R~t_to_unicodeRqt	Exception(R.tproposedterrorsRJtsmart_quotes_retsmart_quotes_compiledRtRS((s./usr/lib/python2.7/site-packages/bs4/dammit.pyRr�s"		
cCst|||�S(sGiven a string and its encoding, decodes the string into Unicode.
        %encoding is a string recognized by encodings.aliases(RV(R.RXRR�((s./usr/lib/python2.7/site-packages/bs4/dammit.pyR��scCs|js
dS|jjS(N(RGRRoRH(R.((s./usr/lib/python2.7/site-packages/bs4/dammit.pytdeclared_html_encoding�s	cCs�|j|jj||��pu|r?|j|jdd��pu|r`|j|jdd��pu|rr|j�pu|}|r�|j�SdS(Nt-R
t_(t_codectCHARSET_ALIASESR%R-RDR(R.tcharsetR/((s./usr/lib/python2.7/site-packages/bs4/dammit.pyR��s!!
cCsE|s
|Sd}ytj|�|}Wnttfk
r@nX|S(N(RtcodecsRtLookupErrort
ValueError(R.R�tcodec((s./usr/lib/python2.7/site-packages/bs4/dammit.pyR��s

teurot20ACs�t s�tsbquot201As�tfnoft192s�tbdquot201Es�thellipt2026s�tdaggert2020s�tDaggert2021s�tcirct2C6s�tpermilt2030s�tScaront160s�tlsaquot2039s�tOEligt152s�t?s�s#x17Dt17Ds�s�s�tlsquot2018s�trsquot2019s�tldquot201Cs�trdquot201Ds�tbullt2022s�tndasht2013s�tmdasht2014s�ttildet2DCs�ttradet2122s�tscaront161s�trsaquot203As�toeligt153s�s�s#x17Et17Es�tYumlR
s�tEURt,tfs,,s...t+s++t^t%tSR!tOEtZRRt*R�s--t~s(TM)RR#toetztYs�t!s�tcs�tGBPs�t$s�tYENs�t|s�s�s..s�s�s(th)s�s<<s�s�s�s(R)s�s�tos�s+-s�t2s�t3s�tacutes�Rts�tPs�s�s�t1s�s�s>>s�s1/4s�s1/2s�s3/4s�s�tAs�s�s�s�s�s�tAEs�tCs�tEs�s�s�s�tIs�s�s�s�tDs�tNs�tOs�s�s�s�s�s�s�tUs�s�s�s�s�tbs�tBs�tas�s�s�s�s�s�taes�s�RSs�s�s�s�tis�s�s�s�s�tns�s�s�s�s�s�t/s�s�s�s�s�s�tys�s�s�s€i�s‚i�sƒi�s„i�s…i�s†i�s‡i�sˆi�s‰i�sŠi�s‹i�sŒi�sŽi�s‘i�s’i�s“i�s”i�s•i�s–i�s—i�s˜i�s™i�sši�s›i�sœi�sži�sŸi�s i�s¡i�s¢i�s£i�s¤i�s¥i�s¦i�s§i�s¨i�s©i�sªi�s«i�s¬i�s­i�s®i�s¯i�s°i�s±i�s²i�s³i�s´i�sµi�s¶i�s·i�s¸i�s¹i�sºi�s»i�s¼i�s½i�s¾i�s¿i�sÀi�sÁi�sÂi�sÃi�sÄi�sÅi�sÆi�sÇi�sÈi�sÉi�sÊi�sËi�sÌi�sÍi�sÎi�sÏi�sÐi�sÑi�sÒi�sÓi�sÔi�sÕi�sÖi�s×i�sØi�sÙi�sÚi�sÛi�sÜi�sÝi�sÞi�sßi�sài�i�sâi�sãi�säi�såi�sæi�sçi�sèi�séi�sêi�sëi�sìi�síi�sîi�sïi�sði�sñi�sòi�sói�sôi�sõi�söi�s÷i�søi�sùi�súi�sûi�süi�sýi�sþi�iiiii����itutf8cCs�|jdd�j�d
kr-td��n|j�dkrNtd��ng}d	}d	}x|t|�krd||}t|t�s�t|�}n||jkr||jkrx�|j	D]5\}}	}
||kr�||	kr�||
7}Pq�q�Wqc|d
krW||j
krW|j|||!�|j|j
|�|d7}|}qc|d7}qcW|d	kru|S|j||�dj|�S(s�Fix characters from one encoding embedded in some other encoding.

        Currently the only situation supported is Windows-1252 (or its
        subset ISO-8859-1), embedded in UTF-8.

        The input must be a bytestring. If you've already converted
        the document to Unicode, you're too late.

        The output is a bytestring in which `embedded_encoding`
        characters have been converted to their `main_encoding`
        equivalents.
        R�R�swindows-1252twindows_1252sPWindows-1252 and ISO-8859-1 are the only currently supported embedded encodings.R�sutf-8s4UTF-8 is the only currently supported main encoding.ii�iR
(swindows-1252R�(R�sutf-8(
R-RDtNotImplementedErrorRWRUR\tordtFIRST_MULTIBYTE_MARKERtLAST_MULTIBYTE_MARKERtMULTIBYTE_MARKERS_AND_SIZEStWINDOWS_1252_TO_UTF8RR(R'tin_bytest
main_encodingtembedded_encodingtbyte_chunkstchunk_starttpostbytetstarttendtsize((s./usr/lib/python2.7/site-packages/bs4/dammit.pyt	detwingles<	


	N(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(s#x17DR�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(R�R�(s#x17ER�(R�R
(RR�(i�i�i(i�i�i(i�i�i(R;R<R=R�R�RR@RMR~RrR�RfR�R�R�RyRwR�R�R�R�R?R(((s./usr/lib/python2.7/site-packages/bs4/dammit.pyRgEsd

	1			



	(((R=t__license__R�thtmlentitydefsRRRltstringRtchardet_typeRRtImportErrorRticonv_codecRRxR�R]R_tobjectR	RARg(((s./usr/lib/python2.7/site-packages/bs4/dammit.pyt<module>s6




�