403Webshell
Server IP : 192.158.238.246  /  Your IP : 13.59.14.52
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib/python3.7/site-packages/bs4/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib/python3.7/site-packages/bs4/__pycache__/dammit.cpython-37.pyc
B

�.�`�t�@s
dZdZddlZddlmZddlZddlZddlZdZyddl	Z	dd�Z
WnFek
r�yddlZdd�Z
Wnek
r�dd�Z
YnXYnXyddl
Z
Wnek
r�YnXe�d	��ej�Ze�d
��ej�ZGdd�de�ZGd
d�d�ZGdd�d�ZdS)aBBeautiful 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.
�MIT�N)�codepoint2namecCst�|�dS)N�encoding)�cchardet�detect)�s�r�;/opt/alt/python37/lib/python3.7/site-packages/bs4/dammit.py�chardet_dammitsr
cCst�|�dS)Nr)�chardetr)rrrr	r
!scCsdS)Nr)rrrr	r
'sz!^<\?.*encoding=['"](.*?)['"].*\?>z0<\s*meta[^>]+charset\s*=\s*["']?([^>]*?)[ /;'">]c@s�eZdZdZdd�Ze�\ZZZdddddd	�Ze	�
d
�Ze	�
d�Ze
dd
��Ze
dd��Ze
dd��Ze
ddd��Ze
ddd��Ze
dd��ZdS)�EntitySubstitutionzASubstitute XML or HTML entities for the corresponding characters.cCsni}i}g}xBtt���D]2\}}t|�}|dkrD|�|�|||<|||<qWdd�|�}||t�|�fS)N�"z[%s]�)�listr�items�chr�append�join�re�compile)�lookupZreverse_lookupZcharacters_for_reZ	codepoint�name�	characterZ
re_definitionrrr	�_populate_class_variables9s
z,EntitySubstitution._populate_class_variablesZaposZquotZamp�lt�gt)�'�"�&�<�>z&([<>]|&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;))z([<>&])cCs|j�|�d��}d|S)Nrz&%s;)�CHARACTER_TO_HTML_ENTITY�get�group)�cls�matchobj�entityrrr	�_substitute_html_entityZsz*EntitySubstitution._substitute_html_entitycCs|j|�d�}d|S)zmUsed with a regular expression to substitute the
        appropriate XML entity for an XML special character.rz&%s;)�CHARACTER_TO_XML_ENTITYr#)r$r%r&rrr	�_substitute_xml_entity_sz)EntitySubstitution._substitute_xml_entitycCs6d}d|kr*d|kr&d}|�d|�}nd}|||S)a*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;
        rrz&quot;)�replace)�self�valueZ
quote_withZreplace_withrrr	�quoted_attribute_valuefsz)EntitySubstitution.quoted_attribute_valueFcCs"|j�|j|�}|r|�|�}|S)aSubstitute 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.
        )�AMPERSAND_OR_BRACKET�subr)r-)r$r,�make_quoted_attributerrr	�substitute_xml�s


z!EntitySubstitution.substitute_xmlcCs"|j�|j|�}|r|�|�}|S)a�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.
        )�BARE_AMPERSAND_OR_BRACKETr/r)r-)r$r,r0rrr	�"substitute_xml_containing_entities�s


z5EntitySubstitution.substitute_xml_containing_entitiescCs|j�|j|�S)a�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.
        )�CHARACTER_TO_HTML_ENTITY_REr/r')r$rrrr	�substitute_html�sz"EntitySubstitution.substitute_htmlN)F)F)�__name__�
__module__�__qualname__�__doc__rr!ZHTML_ENTITY_TO_CHARACTERr4r(rrr2r.�classmethodr'r)r-r1r3r5rrrr	r5s$

%rc@sHeZdZdZddd�Zdd�Zedd	��Zed
d��Z	eddd
��Z
dS)�EncodingDetectora^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.
    NFcCsN|pg|_|pg}tdd�|D��|_d|_||_d|_|�|�\|_|_dS)NcSsg|]}|���qSr)�lower)�.0�xrrr	�
<listcomp>�sz-EncodingDetector.__init__.<locals>.<listcomp>)	�override_encodings�set�exclude_encodings�chardet_encoding�is_html�declared_encoding�strip_byte_order_mark�markup�sniffed_encoding)r+rGr@rDrBrrr	�__init__�s
zEncodingDetector.__init__cCs8|dk	r4|��}||jkrdS||kr4|�|�dSdS)NFT)r<rB�add)r+r�triedrrr	�_usable�s

zEncodingDetector._usableccs�t�}x |jD]}|�||�r|VqW|�|j|�r>|jV|jdkrZ|�|j|j�|_|�|j|�rp|jV|jdkr�t	|j�|_|�|j|�r�|jVxdD]}|�||�r�|Vq�WdS)z<Yield a number of encodings that might work for this markup.N)zutf-8zwindows-1252)
rAr@rLrHrE�find_declared_encodingrGrDrCr
)r+rK�errr	�	encodings�s$



zEncodingDetector.encodingscCs�d}t|t�r||fSt|�dkrT|dd�dkrT|dd�dkrTd}|dd�}n�t|�dkr�|dd�dkr�|dd�dkr�d}|dd�}nd|dd	�d
kr�d}|d	d�}nB|dd�dkr�d
}|dd�}n |dd�dkr�d}|dd�}||fS)zMIf a byte-order mark is present, strip it and return the encoding it implies.N��s��zzutf-16bes��zutf-16le�szutf-8s��zutf-32bes��zutf-32le)�
isinstance�str�len)r$�datarrrr	rFs*
z&EncodingDetector.strip_byte_order_markcCs�|rt|�}}nd}tdtt|�d��}d}tj||d�}|sT|rTtj||d�}|dk	rp|��d�dd�}|r||��SdS)	z�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�������?N)�endposr�asciir*)	rU�max�int�xml_encoding_re�search�html_meta_re�groups�decoder<)r$rGrDZsearch_entire_documentZ
xml_endposZhtml_endposrEZdeclared_encoding_matchrrr	rM+s	z'EncodingDetector.find_declared_encoding)NFN)FF)r6r7r8r9rIrL�propertyrOr:rFrMrrrr	r;�s

!r;c�@s�eZdZdZddd�ZdddgZgdd	gfd
d�Zdd
�Zd�dd�Zd�dd�Z	e
dd��Zdd�Zdd�Z
dddddddd d!d"d#d$d%d&d'd&d&d(d)d*d+d,d-d.d/d0d1d2d3d&d4d5d6� Zd7dd8d9d:d;d<d=d>d?d@dAdBd&dCd&d&dDdDdEdEdFdGdHdIdJdKdLdMd&dNdOddPdQdRdSdTdUd@dVdWdXdYdPddZdGd[d\d]d^d_d`dadFd8dbdXdcdddedfd&dgdgdgdgdgdgdhdidjdjdjdjdkdkdkdkdldmdndndndndndFdndododododOdpdqdrdrdrdrdrdrdsdQdtdtdtdtdudududud[dvd[d[d[d[d[dwd[d`d`d`d`dxdpdxdy��Zdzd{d|d}d~dd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�zZd�d�d�gZed�d�Zed�d�Ze�dd�d���ZdS(�
UnicodeDammitz�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.z	mac-romanz	shift-jis)�	macintoshzx-sjis�windows-1252z
iso-8859-1z
iso-8859-2NFcCs�||_g|_d|_||_t�t�|_t||||�|_	t
|t�sF|dkr`||_t|�|_
d|_dS|j	j|_d}x,|j	jD] }|j	j}|�|�}|dk	rxPqxW|s�x@|j	jD]4}|dkr�|�|d�}|dk	r�|j�d�d|_Pq�W||_
|s�d|_dS)NFrrXr*zSSome characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.T)�smart_quotes_to�tried_encodingsZcontains_replacement_charactersrD�loggingZ	getLoggerr6�logr;�detectorrSrTrGZunicode_markup�original_encodingrO�
_convert_fromZwarning)r+rGr@rdrDrB�urrrr	rIXs>


zUnicodeDammit.__init__cCs�|�d�}|jdkr&|j�|���}nf|j�|�}t|�tkr�|jdkrfd��|d��d��}q�d��|d��d��}n|��}|S)z[Changes a MS smart quote character to an XML or HTML
        entity, or an ASCII character.�rX�xmlz&#x�;rr)r#rd�MS_CHARS_TO_ASCIIr"�encode�MS_CHARS�type�tuple)r+�match�origr/rrr	�_sub_ms_char�s


zUnicodeDammit._sub_ms_char�strictc
Cs�|�|�}|r||f|jkr dS|j�||f�|j}|jdk	rf||jkrfd}t�|�}|�|j	|�}y|�
|||�}||_||_Wn"tk
r�}zdSd}~XYnX|jS)Ns([�-�]))
�
find_codecrerrGrd�ENCODINGS_WITH_SMART_QUOTESrrr/rv�_to_unicoderi�	Exception)r+Zproposed�errorsrGZsmart_quotes_reZsmart_quotes_compiledrkrNrrr	rj�s"




zUnicodeDammit._convert_fromcCst|||�S)zGiven a string and its encoding, decodes the string into Unicode.
        %encoding is a string recognized by encodings.aliases)rT)r+rVrr|rrr	rz�szUnicodeDammit._to_unicodecCs|js
dS|jjS)N)rDrhrE)r+rrr	�declared_html_encoding�sz$UnicodeDammit.declared_html_encodingcCs`|�|j�||��pN|r*|�|�dd��pN|r@|�|�dd��pN|rL|��pN|}|r\|��SdS)N�-r�_)�_codec�CHARSET_ALIASESr"r*r<)r+�charsetr,rrr	rx�szUnicodeDammit.find_codecc	Cs<|s|Sd}yt�|�|}Wnttfk
r6YnX|S)N)�codecsr�LookupError�
ValueError)r+r��codecrrr	r��s
zUnicodeDammit._codec)�euroZ20AC� )ZsbquoZ201A)ZfnofZ192)ZbdquoZ201E)ZhellipZ2026)ZdaggerZ2020)ZDaggerZ2021)ZcircZ2C6)ZpermilZ2030)ZScaronZ160)ZlsaquoZ2039)ZOEligZ152�?)z#x17DZ17D)ZlsquoZ2018)ZrsquoZ2019)ZldquoZ201C)ZrdquoZ201D)ZbullZ2022)ZndashZ2013)ZmdashZ2014)�tildeZ2DC)ZtradeZ2122)ZscaronZ161)ZrsaquoZ203A)ZoeligZ153)z#x17EZ17E)ZYumlr) ����������������������������������������������������������������ZEUR�,�fz,,z...�+z++�^�%�SrZOE�Zrr�*r~z--�~z(TM)rr Zoe�z�Y�!�cZGBP�$ZYEN�|z..rz(th)z<<z(R)�oz+-�2�3)rZacuterk�P�1z>>z1/4z1/2z3/4�AZAE�C�E�I�D�N�O�U�b�B�aZaerN�i�n�/�y)�r�r�r�r�r�r�r�r�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€s‚sƒs„s…s†s‡sˆs‰sŠs‹sŒsŽs‘s’s“s”s•s–s—s˜s™sšs›sœsžsŸs s¡s¢s£s¤s¥s¦s§s¨s©sªs«s¬s­s®s¯s°s±s²s³s´sµs¶s·s¸s¹sºs»s¼s½s¾s¿sÀsÁsÂsÃsÄsÅsÆsÇsÈsÉsÊsËsÌsÍsÎsÏsÐsÑsÒsÓsÔsÕsÖs×sØsÙsÚsÛsÜsÝsÞsßsàr�sâsãsäsåsæsçsèsésêsësìsísîsïsðsñsòsósôsõsös÷søsùsúsûsüsýsþ)z�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������)rkr�rQ)r�r�rR)r�r�rPr���rl�utf8cCs"|�dd���dkrtd��|��dkr0td��g}d}d}x�|t|�kr�||}t|t�sdt|�}||jkr�||jkr�xz|j	D]$\}}	}
||kr�||	kr�||
7}Pq�Wq>|dkr�||j
kr�|�|||��|�|j
|�|d	7}|}q>|d	7}q>W|dk�r|S|�||d
��d�|�S)a�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.
        rr~)zwindows-1252�windows_1252zPWindows-1252 and ISO-8859-1 are the only currently supported embedded encodings.)r�zutf-8z4UTF-8 is the only currently supported main encoding.rr.rlN�)
r*r<�NotImplementedErrorrUrSrZ�ord�FIRST_MULTIBYTE_MARKER�LAST_MULTIBYTE_MARKER�MULTIBYTE_MARKERS_AND_SIZES�WINDOWS_1252_TO_UTF8rr)r$Zin_bytesZ
main_encodingZembedded_encodingZbyte_chunksZchunk_start�posZbyte�start�end�sizerrr	�	detwingles<



zUnicodeDammit.detwingle)rw)rw)r�rc)r6r7r8r9r�ryrIrvrjrzr`r}rxr�rqror�r�r�r�r:r�rrrr	raEs`1


	ra)r9�__license__r�Z
html.entitiesrrrf�stringZchardet_typerr
�ImportErrorrZiconv_codecrrpr�r[r]�objectrr;rarrrr	�<module>s8

Youez - 2016 - github.com/yon3zu
LinuXploit