a
    ÷£Be  ã                   @   sÆ   d dl mZ G dd„ deƒZG dd„ deƒZG dd„ deƒZeejd�ejd	< eejd
dd�ejd< eejd�ejd< ed
d�ejd
< eejd�ejd	< eejd�ejd< eeejd
d�ƒejd
< d
S )é    )ÚEntitySubstitutionc                   @   s\   e Zd ZdZi Zi ZdZdZee	ddgƒd�Z
dd„ Zddd„Zdd„ Zdd„ Zdd„ Zd	S )Ú	Formattera   Describes 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_tagsc                 C   s&   |d ur|S || j krtƒ S | j| S ©N)ÚXMLÚsetÚHTML_DEFAULTS)ÚselfÚlanguageÚvalueÚkwarg© r   úP/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/bs4/formatter.pyÚ_default*   s
    
zFormatter._defaultNú/Fé   c                 C   sr   || _ || _|| _|  ||d¡| _|| _|du r4d}t|tƒrT|dk rJd}d| }nt|tƒrd|}nd}|| _	dS )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 "	"), that string
            is used to indent each level. The default behavior to
            indent one space per level.
        r   Nr   ú )
r   Úentity_substitutionÚvoid_element_close_prefixr   r   Úempty_attributes_are_booleansÚ
isinstanceÚintÚstrÚindent)r   r   r   r   r   r   r   r   r   r   Ú__init__1   s"    !ÿ


zFormatter.__init__c                 C   sF   | j s
|S ddlm} t||ƒr<|jdur<|jj| jv r<|S |   |¡S )a  Process 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   Úelementr   r   ÚparentÚnamer   )r   Únsr   r   r   r   Ú
substitutee   s    	
ÿþzFormatter.substitutec                 C   s
   |   |¡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   r   r   r   r   Úattribute_valuey   s    zFormatter.attribute_valuec                    s.   |j du rg S t‡ fdd„t|j  ¡ ƒ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.
        Nc                 3   s,   | ]$\}}|ˆ j r|d krdn|fV  qdS )Ú N)r   )Ú.0ÚkÚv©r   r   r   Ú	<genexpr>�   s   ÿz'Formatter.attributes.<locals>.<genexpr>)ÚattrsÚsortedÚlistÚitems)r   Útagr   r*   r   Ú
attributes‚   s
    
þzFormatter.attributes)NNr   NFr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ZXML_FORMATTERSZHTML_FORMATTERSÚHTMLr
   Údictr   r   r   r   r$   r%   r1   r   r   r   r   r      s    
ÿ   ý
4	r   c                       s$   e Zd ZdZi Z‡ fdd„Z‡  ZS )ÚHTMLFormatterzA generic Formatter for HTML.c                    s$   t t| ƒj| jg|¢R i |¤Ž d S r	   )Úsuperr8   r   r6   ©r   ÚargsÚkwargs©Ú	__class__r   r   r   —   s    zHTMLFormatter.__init__©r2   r3   r4   r5   ÚREGISTRYr   Ú__classcell__r   r   r=   r   r8   ”   s   r8   c                       s$   e Zd ZdZi Z‡ fdd„Z‡  ZS )ÚXMLFormatterzA generic Formatter for XML.c                    s$   t t| ƒj| jg|¢R i |¤Ž d S r	   )r9   rB   r   r
   r:   r=   r   r   r   ž   s    zXMLFormatter.__init__r?   r   r   r=   r   rB   ›   s   rB   )r   r   NT)r   r   r   Úhtml5Zminimal)	Z
bs4.dammitr   r   r8   rB   Zsubstitute_htmlr@   Zsubstitute_xmlr
   r   r   r   r   Ú<module>   s6    ÿýÿÿÿÿÿ