
    ^h4                     "   S SK JrJrJr  S SKJr  SSKJrJrJ	r	  / SQr
\R                  r\R                  r\R                  r\R"                  r\R&                  r\R*                  rSrSR1                  \	5      r	 " S S	\5      r " S
 S\5      rg)    )absolute_importdivisionunicode_literals)Node   )
namespacesvoidElementsspaceCharacters)	DOCUMENTDOCTYPETEXTELEMENTCOMMENTENTITYUNKNOWN
TreeWalkerNonRecursiveTreeWalkerz<#UNKNOWN#> c                   b    \ rS rSrSrS rS rS rSS jrS r	S r
S	 rS
 rSS jrS rS rSrg)r      zqWalks a tree yielding tokens

Tokens are dicts that all have a ``type`` field specifying the type of the
token.

c                     Xl         g)z3Creates a TreeWalker

:arg tree: the tree to walk

Ntree)selfr   s     b/home/james-whalen/.local/lib/python3.13/site-packages/bleach/_vendor/html5lib/treewalkers/base.py__init__TreeWalker.__init__   s	     	    c                     [         eNNotImplementedError)r   s    r   __iter__TreeWalker.__iter__#       !!r   c                     SUS.$ )znGenerates an error token with the given message

:arg msg: the error message

:returns: SerializeError token

SerializeErrortypedata )r   msgs     r   errorTreeWalker.error&   s     )#66r   c              #   T   #    SUUUS.v   U(       a  U R                  S5      v   gg7f)a:  Generates an EmptyTag token

:arg namespace: the namespace of the token--can be ``None``

:arg name: the name of the element

:arg attrs: the attributes of the element as a dict

:arg hasChildren: whether or not to yield a SerializationError because
    this tag shouldn't have children

:returns: EmptyTag token

EmptyTagr)   name	namespacer*   zVoid element has childrenNr-   )r   r3   r2   attrshasChildrens        r   emptyTagTreeWalker.emptyTag0   s6      "4% 	 **899 s   &(c                     SUUUS.$ )zGenerates a StartTag token

:arg namespace: the namespace of the token--can be ``None``

:arg name: the name of the element

:arg attrs: the attributes of the element as a dict

:returns: StartTag token

StartTagr1   r+   )r   r3   r2   r5   s       r   startTagTreeWalker.startTagE   s     #& 	r   c                     SUUS.$ )zGenerates an EndTag token

:arg namespace: the namespace of the token--can be ``None``

:arg name: the name of the element

:returns: EndTag token

EndTag)r)   r2   r3   r+   )r   r3   r2   s      r   endTagTreeWalker.endTagV   s     !&( 	(r   c              #     #    UnUR                  [        5      nUS[        U5      [        U5      -
   nU(       a  SUS.v   UnUR                  [        5      nU[        U5      S nU(       a  SUS.v   U(       a  SUS.v   gg7f)a  Generates SpaceCharacters and Characters tokens

Depending on what's in the data, this generates one or more
``SpaceCharacters`` and ``Characters`` tokens.

For example:

    >>> from html5lib.treewalkers.base import TreeWalker
    >>> # Give it an empty tree just so it instantiates
    >>> walker = TreeWalker([])
    >>> list(walker.text(''))
    []
    >>> list(walker.text('  '))
    [{u'data': '  ', u'type': u'SpaceCharacters'}]
    >>> list(walker.text(' abc '))  # doctest: +NORMALIZE_WHITESPACE
    [{u'data': ' ', u'type': u'SpaceCharacters'},
    {u'data': u'abc', u'type': u'Characters'},
    {u'data': u' ', u'type': u'SpaceCharacters'}]

:arg data: the text data

:returns: one or more ``SpaceCharacters`` and ``Characters`` tokens

NSpaceCharactersr(   
Characters)lstripr
   lenrstrip)r   r*   middleleftrights        r   textTreeWalker.textd   s     2 _-,SYV,-,d;;_-S[\"'88,e<< s   BBc                     SUS.$ )zLGenerates a Comment token

:arg data: the comment

:returns: Comment token

Commentr(   r+   )r   r*   s     r   commentTreeWalker.comment   s     "400r   Nc                     SUUUS.$ )zdGenerates a Doctype token

:arg name:

:arg publicId:

:arg systemId:

:returns: the Doctype token

Doctype)r)   r2   publicIdsystemIdr+   )r   r2   rR   rS   s       r   doctypeTreeWalker.doctype   s     "$$& 	&r   c                     SUS.$ )zRGenerates an Entity token

:arg name: the entity name

:returns: an Entity token

Entity)r)   r2   r+   )r   r2   s     r   entityTreeWalker.entity   s     !$//r   c                 *    U R                  SU-   5      $ )zHandles unknown node typeszUnknown node type: r4   )r   nodeTypes     r   unknownTreeWalker.unknown   s    zz/(:;;r   r   )F)NN)__name__
__module____qualname____firstlineno____doc__r   r#   r-   r7   r;   r?   rJ   rN   rT   rX   r\   __static_attributes__r+   r   r   r   r      s?    "7:*"($=L1&"0<r   r   c                   2    \ rS rSrS rS rS rS rS rSr	g)	r      c                     [         er    r!   r   nodes     r   getNodeDetails%NonRecursiveTreeWalker.getNodeDetails   r%   r   c                     [         er    r!   rg   s     r   getFirstChild$NonRecursiveTreeWalker.getFirstChild   r%   r   c                     [         er    r!   rg   s     r   getNextSibling%NonRecursiveTreeWalker.getNextSibling   r%   r   c                     [         er    r!   rg   s     r   getParentNode$NonRecursiveTreeWalker.getParentNode   r%   r   c              #     #    U R                   nUGb  U R                  U5      nUS   USS  p#SnU[        :X  a  U R                  " U6 v   OU[        :X  a  U R
                  " U6  H  nUv   M	     OU[        :X  aY  Uu  pgpU(       a  U[        S   :X  a+  U[        ;   a!  U R                  XgUU5       H  nUv   M	     SnOzU R                  XgU5      v   OeU[        :X  a  U R                  US   5      v   ODU[        :X  a  U R                  US   5      v   O#U[        :X  a  SnOU R!                  US   5      v   U(       a  U R#                  U5      n	OS n	U	b  U	nOUb  U R                  U5      nUS   USS  p#U[        :X  a6  Uu  pgpU(       a  U[        S   :w  d
  U[        ;  a  U R%                  Xg5      v   U R                   UL a  S nO-U R'                  U5      n
U
b  U
nOU R)                  U5      nUb  M  Ub  GM  g g 7f)Nr      FhtmlT)r   ri   r   rT   r   rJ   r   r   r	   r7   r;   r   rN   r   rX   r   r\   rl   r?   ro   rr   )r   currentNodedetailsr)   r6   tokenr3   r2   
attributes
firstChildnextSiblings              r   r#   NonRecursiveTreeWalker.__iter__   s    ii%))+6G#AJ'KwllG,,!YY0EK 1 ;B8	!Y*V2D%D$R^J^!%y
/:"<#"< #(K--	DDll71:..kk'!*--!" ll71:..!//<
!
%(!-"11+>G$+AJ'wCJ@	%)z&7I*IdZfNf"&++i">>yyK/&*"&"5"5k"BK".&1&*&8&8&E "-U %s   G1G=5G=;G=r+   N)
r^   r_   r`   ra   ri   rl   ro   rr   r#   rc   r+   r   r   r   r      s    """";Fr   r   N)
__future__r   r   r   xml.domr   	constantsr   r	   r
   __all__DOCUMENT_NODEr   DOCUMENT_TYPE_NODEr   	TEXT_NODEr   ELEMENT_NODEr   COMMENT_NODEr   ENTITY_NODEr   r   joinobjectr   r   r+   r   r   <module>r      s    B B  A A3 

!
!~~





			
''/*]< ]<@HFZ HFr   