Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pyo

ó
“tÆ_c@`sddlmZmZmZddlmZddlZddlmZm	Z	ddl
mZmZm
Z
ddl
mZmZmZddlmZmZdd	lmZd
je
ƒdZejded
ƒZejdedƒZiZedƒdkZx»eejƒƒD]§\Z Z!eo9ee!ƒdkpReoRee!ƒdkr[qne!dkr¿ee!ƒdkr‹ej"e!ƒZ!ne#e!ƒZ!e!ekp¬e j$ƒr¼e ee!<nnqWd„Z%ede%ƒde&d„Z'de(fd„ƒYZ)de*fd„ƒYZ+dS(i(tabsolute_importtdivisiontunicode_literals(t	text_typeN(tregister_errortxmlcharrefreplace_errorsi(tvoidElementstbooleanAttributestspaceCharacters(trcdataElementstentitiestxmlEntities(ttreewalkerst_utils(tescapeuu"'=<>`u[u]u_	

 /`  ᠎á â€€â€â€‚        

 âŸã€€]uô¿¿iu&c
C`st|ttfƒrqg}g}t}x´t|j|j|j!ƒD]–\}}|rbt}qDn||j}tj	|j|t
|j|dgƒ!ƒrÁtj|j||d!ƒ}t}nt
|ƒ}|j|ƒqDWxz|D]r}tj|ƒ}	|	r<|jdƒ|j|	ƒ|	jdƒsW|jdƒqWqå|jdt|ƒdƒqåWdj|ƒ|jfSt|ƒSdS(Niu&u;u&#x%s;u(t
isinstancetUnicodeEncodeErrortUnicodeTranslateErrortFalset	enumeratetobjecttstarttendR
tisSurrogatePairtmintsurrogatePairToCodepointtTruetordtappendt_encode_entity_maptgettendswiththextjoinR(
texctrest
codepointstskiptitctindext	codepointtcpte((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pythtmlentityreplace_errors*s0)
,	


uhtmlentityreplaceuetreecK`s1tj|ƒ}t|}|j||ƒ|ƒS(u˜Serializes the input token stream using the specified treewalker

    :arg input: the token stream to serialize

    :arg tree: the treewalker to use

    :arg encoding: the encoding to use

    :arg serializer_opts: any options to pass to the
        :py:class:`html5lib.serializer.HTMLSerializer` that gets created

    :returns: the tree serialized as a string

    Example:

    >>> from html5lib.html5parser import parse
    >>> from html5lib.serializer import serialize
    >>> token_stream = parse('<html><body><p>Hi!</p></body></html>')
    >>> serialize(token_stream, omit_optional_tags=False)
    '<html><head></head><body><p>Hi!</p></body></html>'

    (Rt
getTreeWalkertHTMLSerializertrender(tinputttreetencodingtserializer_optstwalkerts((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pyt	serializeKsR.cB`s¡eZdZdZeZeZeZeZ	eZ
eZeZeZ
eZeZeZeZdZd„Zd„Zd„Zdd„Zdd„Zdd„ZRS(ulegacyu"uquote_attr_valuesu
quote_charuuse_best_quote_charuomit_optional_tagsuminimize_boolean_attributesuuse_trailing_solidususpace_before_trailing_solidusuescape_lt_in_attrsu
escape_rcdatauresolve_entitiesualphabetical_attributesuinject_meta_charsetustrip_whitespaceusanitizec	K`s±t|ƒt|jƒ}t|ƒdkrJtdtt|ƒƒƒ‚nd|krbt|_nx6|jD]+}t|||j	|t
||ƒƒƒqlWg|_t|_dS(uB
Initialize HTMLSerializer

        :arg inject_meta_charset: Whether or not to inject the meta charset.

            Defaults to ``True``.

        :arg quote_attr_values: Whether to quote attribute values that don't
            require quoting per legacy browser behavior (``"legacy"``), when
            required by the standard (``"spec"``), or always (``"always"``).

            Defaults to ``"legacy"``.

        :arg quote_char: Use given quote character for attribute quoting.

            Defaults to ``"`` which will use double quotes unless attribute
            value contains a double quote, in which case single quotes are
            used.

        :arg escape_lt_in_attrs: Whether or not to escape ``<`` in attribute
            values.

            Defaults to ``False``.

        :arg escape_rcdata: Whether to escape characters that need to be
            escaped within normal elements within rcdata elements such as
            style.

            Defaults to ``False``.

        :arg resolve_entities: Whether to resolve named character entities that
            appear in the source tree. The XML predefined entities &lt; &gt;
            &amp; &quot; &apos; are unaffected by this setting.

            Defaults to ``True``.

        :arg strip_whitespace: Whether to remove semantically meaningless
            whitespace. (This compresses all whitespace to a single space
            except within ``pre``.)

            Defaults to ``False``.

        :arg minimize_boolean_attributes: Shortens boolean attributes to give
            just the attribute value, for example::

              <input disabled="disabled">

            becomes::

              <input disabled>

            Defaults to ``True``.

        :arg use_trailing_solidus: Includes a close-tag slash at the end of the
            start tag of void elements (empty elements whose end tag is
            forbidden). E.g. ``<hr/>``.

            Defaults to ``False``.

        :arg space_before_trailing_solidus: Places a space immediately before
            the closing slash in a tag using a trailing solidus. E.g.
            ``<hr />``. Requires ``use_trailing_solidus=True``.

            Defaults to ``True``.

        :arg sanitize: Strip all unsafe or unknown constructs from output.
            See :py:class:`html5lib.filters.sanitizer.Filter`.

            Defaults to ``False``.

        :arg omit_optional_tags: Omit start/end tags that are optional.

            Defaults to ``True``.

        :arg alphabetical_attributes: Reorder attributes to be in alphabetical order.

            Defaults to ``False``.

        iu2__init__() got an unexpected keyword argument '%s'u
quote_charN(
t	frozensettoptionstlent	TypeErrortnexttiterRtuse_best_quote_chartsetattrRtgetattrterrorststrict(tselftkwargstunexpected_argstattr((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pyt__init__‡sO)	cC`s$|jr|j|jdƒS|SdS(Nuhtmlentityreplace(R2tencode(RBtstring((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pyRGàs	cC`s$|jr|j|jdƒS|SdS(Nustrict(R2RG(RBRH((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pytencodeStrictçs	cc`sn||_t}g|_|rI|jrIddlm}|||ƒ}n|jrqddlm}||ƒ}n|jr™ddl	m}||ƒ}n|j
rÁddlm}||ƒ}n|jréddl
m}||ƒ}nx~|D]v}|d}|dkräd|d}|dr9|d|d7}n|d	rP|d
7}n|d	rÉ|d	jdƒdkr¥|d	jd
ƒdkrœ|jdƒnd
}nd}|d||d	|f7}n|d7}|j|ƒVqð|d3kra|dks|rF|r1|djdƒdkr1|jdƒn|j|dƒVqf|jt|dƒƒVqð|d4kr.|d}	|jd|	ƒV|	tkr¨|jr¨t}n|r¾|jdƒnx|djƒD]
\\}
}}|}
|}|jdƒV|j|
ƒV|jsI|
tj|	tƒƒkrÏ|
tjdtƒƒkrÏ|jdƒV|jdksxt|ƒdkrt}nZ|jdkr¨tj|ƒdk	}n3|jdkrÏt j|ƒdk	}nt!d ƒ‚|j"d!d"ƒ}|j#r|j"d#d$ƒ}n|rÈ|j$}|j%rhd
|krDd|krDd}qhd|krhd
|krhd
}qhn|d
kr‰|j"d
d%ƒ}n|j"dd&ƒ}|j|ƒV|j|ƒV|j|ƒVqÙ|j|ƒVqÏqÏW|	t&kr|j'r|j(r|jd'ƒVq|jd(ƒVn|jdƒVqð|d)kr„|d}	|	tkrYt}n|ro|jdƒn|jd*|	ƒVqð|d+krØ|d}|jd,ƒdkr¿|jd-ƒn|jd.|dƒVqð|d/krU|d}	|	d0}|t)kr|jd1|	ƒn|j*r:|t+kr:t)|}n
d2|	}|j|ƒVqð|j|dƒqðWdS(5Ni(tFilterutypeuDoctypeu<!DOCTYPE %sunameupublicIdu PUBLIC "%s"usystemIdu SYSTEMu"iu'uBSystem identifier contains both single and double quote charactersu %s%s%su>u
CharactersuSpaceCharactersudatau</uUnexpected </ in CDATAuStartTaguEmptyTagu<%su+Unexpected child element of a CDATA elementu uu=ualwaysuspeculegacyu?quote_attr_values must be one of: 'always', 'spec', or 'legacy'u&u&amp;u<u&lt;u&#39;u&quot;u /u/uEndTagu</%s>uCommentu--uComment contains --u	<!--%s-->uEntityu;uEntity %s not recognizedu&%s;(u
CharactersuSpaceCharacters(uStartTaguEmptyTag(,R2RR@tinject_meta_charsettfilters.inject_meta_charsetRJtalphabetical_attributestfilters.alphabeticalattributeststrip_whitespacetfilters.whitespacetsanitizetfilters.sanitizertomit_optional_tagstfilters.optionaltagstfindtserializeErrorRIRGRR	t
escape_rcdataRtitemstminimize_boolean_attributesRRttupletquote_attr_valuesR9t_quoteAttributeSpectsearchtNonet_quoteAttributeLegacyt
ValueErrortreplacetescape_lt_in_attrst
quote_charR=Rtuse_trailing_solidustspace_before_trailing_solidusR
tresolve_entitiesR(RBt
treewalkerR2tin_cdataRJttokenttypetdoctypeRctnamet_t	attr_namet
attr_valuetktvt
quote_attrtdatatkey((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pyR6îsØ						





	

	#
!						
	




cC`sE|r%djt|j||ƒƒƒSdjt|j|ƒƒƒSdS(unSerializes the stream from the treewalker into a string

        :arg treewalker: the treewalker to serialize

        :arg encoding: the string encoding to use

        :returns: the serialized tree

        Example:

        >>> from html5lib import parse, getTreeWalker
        >>> from html5lib.serializer import HTMLSerializer
        >>> token_stream = parse('<html><body>Hi!</body></html>')
        >>> walker = getTreeWalker('etree')
        >>> serializer = HTMLSerializer(omit_optional_tags=False)
        >>> serializer.render(walker(token_stream))
        '<html><head></head><body>Hi!</body></html>'

        tuN(R!tlistR6(RBRgR2((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pyR/wsuXXX ERROR MESSAGE NEEDEDcC`s&|jj|ƒ|jr"t‚ndS(N(R@RRAtSerializeError(RBRs((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pyRVs	(uquote_attr_valuesu
quote_charuuse_best_quote_charuomit_optional_tagsuminimize_boolean_attributesuuse_trailing_solidususpace_before_trailing_solidusuescape_lt_in_attrsu
escape_rcdatauresolve_entitiesualphabetical_attributesuinject_meta_charsetustrip_whitespaceusanitizeN(t__name__t
__module__R[RcRR=RSRYRRdReRbRWRfRMRKRORQR8RFRGRIR^R6R/RV(((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pyR.hs4	Y		‰RwcB`seZdZRS(uError in serialized tree(RxRyt__doc__(((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pyRw—s(,t
__future__RRRtpip._vendor.sixRtretcodecsRRt	constantsRRRR	R
RRuRR
txml.sax.saxutilsRR!t_quoteAttributeSpecCharstcompileR\R_RR9t_is_ucs4RvRXRpRqRRtislowerR,R^R6RR.t	ExceptionRw(((sP/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/serializer.pyt<module>s:

		
ÿ0
Back to Directory File Manager