HEX
Server: LiteSpeed
System: Linux osault1.hostarmada.net 4.18.0-553.123.2.lve.el8.x86_64 #1 SMP Thu May 7 23:17:13 UTC 2026 x86_64
User: tucom (1048)
PHP: 8.4.24
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.6/site-packages/bs4/__pycache__/formatter.cpython-36.pyc
3

LBj�@s�ddlmZGdd�de�ZGdd�de�ZGdd�de�Zeejd�ejd	<eejd
dd�ejd
<eejd�ejd<ed
d�ejd
<eejd�ejd	<eejd�ejd<eeejd
d��ejd
<d
S)�)�EntitySubstitutionc@s\eZdZdZiZiZdZdZee	ddg�d�Z
dd�Zdd
d�Zdd�Z
dd�Zdd�Zd	S)�	FormatteraDescribes a strategy to use when outputting a parse tree to a string.

    Some parts of this strategy come from the distinction between
    HTML4, HTML5, and XML. Others are configurable by the user.

    Formatters are passed in as the `formatter` argument to methods
    like `PageElement.encode`. Most people won't need to think about
    formatters, and most people who need to think about them can pass
    in one of these predefined strings as `formatter` rather than
    making a new Formatter object:

    For HTML documents:
     * 'html' - HTML entity substitution for generic HTML documents. (default)
     * 'html5' - HTML entity substitution for HTML5 documents, as
                 well as some optimizations in the way tags are rendered.
     * 'minimal' - Only make the substitutions necessary to guarantee
                   valid HTML.
     * None - Do not perform any substitution. This will be faster
              but may result in invalid markup.

    For XML documents:
     * 'html' - Entity substitution for XHTML documents.
     * 'minimal' - Only make the substitutions necessary to guarantee
                   valid XML. (default)
     * None - Do not perform any substitution. This will be faster
              but may result in invalid markup.
    �html�xml�script�style)�cdata_containing_tagscCs&|dk	r|S||jkrt�S|j|S)N)�XML�set�
HTML_DEFAULTS)�self�language�valueZkwarg�r�7/tmp/pip-build-44150kxb/beautifulsoup4/bs4/formatter.py�_default*s

zFormatter._defaultN�/F�cCsr||_||_||_|j||d�|_||_|dkr4d}t|t�rT|dkrJd}d|}nt|t�rd|}nd}||_	dS)a-Constructor.

        :param language: This should be Formatter.XML if you are formatting
           XML markup and Formatter.HTML if you are formatting HTML markup.

        :param entity_substitution: A function to call to replace special
           characters with XML/HTML entities. For examples, see 
           bs4.dammit.EntitySubstitution.substitute_html and substitute_xml.
        :param void_element_close_prefix: By default, void elements
           are represented as <tag/> (XML rules) rather than <tag>
           (HTML rules). To get <tag>, pass in the empty string.
        :param cdata_containing_tags: The list of tags that are defined
           as containing CDATA in this dialect. For example, in HTML,
           <script> and <style> tags are defined as containing CDATA,
           and their contents should not be formatted.
        :param blank_attributes_are_booleans: Render attributes whose value
            is the empty string as HTML-style boolean attributes.
            (Attributes whose value is None are always rendered this way.)

        :param indent: If indent is a non-negative integer or string,
            then the contents of elements will be indented
            appropriately when pretty-printing. An indent level of 0,
            negative, or "" will only insert newlines. Using a
            positive integer indent indents that many spaces per
            level. If indent is a string (such as "\t"), that string
            is used to indent each level. The default behavior is to
            indent one space per level.
        rNr� )
r
�entity_substitution�void_element_close_prefixrr�empty_attributes_are_booleans�
isinstance�int�str�indent)rr
rrrrrrrr�__init__1s !


zFormatter.__init__cCsF|js
|Sddlm}t||�r<|jdk	r<|jj|jkr<|S|j|�S)aProcess a string that needs to undergo entity substitution.
        This may be a string encountered in an attribute value or as
        text.

        :param ns: A string.
        :return: A string with certain characters replaced by named
           or numeric entities.
        r)�NavigableStringN)r�elementrr�parent�namer)r�nsrrrr�
substitutees	

zFormatter.substitutecCs
|j|�S)z�Process the value of an attribute.

        :param ns: A string.
        :return: A string with certain characters replaced by named
           or numeric entities.
        )r")rrrrr�attribute_valueyszFormatter.attribute_valuecs.|jdkrgSt�fdd�t|jj��D��S)a�Reorder a tag's attributes however you want.
        
        By default, attributes are sorted alphabetically. This makes
        behavior consistent between Python 2 and Python 3, and preserves
        backwards compatibility with older versions of Beautiful Soup.

        If `empty_boolean_attributes` is True, then attributes whose
        values are set to the empty string will be treated as boolean
        attributes.
        Nc3s,|]$\}}|�jr|dkrdn|fVqdS)�N)r)�.0�k�v)rrr�	<genexpr>�sz'Formatter.attributes.<locals>.<genexpr>)�attrs�sorted�list�items)r�tagr)rr�
attributes�s


zFormatter.attributes)NNrNFr)�__name__�
__module__�__qualname__�__doc__ZXML_FORMATTERSZHTML_FORMATTERS�HTMLr	�dictr
rrrr"r#r.rrrrrs
1	rcs$eZdZdZiZ�fdd�Z�ZS)�
HTMLFormatterzA generic Formatter for HTML.cstt|�j|jf|�|�dS)N)�superr5rr3)r�args�kwargs)�	__class__rrr�szHTMLFormatter.__init__)r/r0r1r2�REGISTRYr�
__classcell__rr)r9rr5�sr5cs$eZdZdZiZ�fdd�Z�ZS)�XMLFormatterzA generic Formatter for XML.cstt|�j|jf|�|�dS)N)r6r<rr	)rr7r8)r9rrr�szXMLFormatter.__init__)r/r0r1r2r:rr;rr)r9rr<�sr<)rrNT)rrr�html5Zminimal)	Z
bs4.dammitrrr5r<Zsubstitute_htmlr:Zsubstitute_xmlr	rrrr�<module>s(