o
    ýÞh	  ã                   @  sœ   d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ddl
mZmZ er*ddlmZ e	 ¡ Ze	jddd	�Ze e¡ ddd„Zddd„Z		d d!dd„ZdS )"zXML parser for python-docx.é    )Úannotations)ÚTYPE_CHECKINGÚDictÚTypeÚcast)Úetree)ÚNamespacePrefixedTagÚnsmap)ÚBaseOxmlElementTF)Úremove_blank_textÚresolve_entitiesÚxmlústr | bytesÚreturnú'BaseOxmlElement'c                 C  s   t dt | t¡ƒS )z·Root lxml element obtained by parsing XML character string `xml`.

    The custom parser is used, so custom element classes are produced for elements in
    `xml` that have them.
    r
   )r   r   Ú
fromstringÚoxml_parser)r   © r   úP/var/www/html/premium_crap/venv/lib/python3.10/site-packages/docx/oxml/parser.pyÚ	parse_xml   s   r   ÚtagÚstrÚclsúType['BaseOxmlElement']c                 C  s(   |   d¡\}}t t| ¡}|||< dS )zóRegister an lxml custom element-class to use for `tag`.

    A instance of `cls` to be constructed when the oxml parser encounters an element
    with matching `tag`. `tag` is a string of the form `nspfx:tagroot`, e.g.
    `'w:document'`.
    ú:N)ÚsplitÚelement_class_lookupÚget_namespacer	   )r   r   ÚnspfxÚtagrootÚ	namespacer   r   r   Úregister_element_cls    s   r!   NÚ
nsptag_strÚattrsúDict[str, str] | NoneÚnsdeclsú BaseOxmlElement | etree._Elementc                 C  s(   t | ƒ}|du r|j}tj|j||d�S )al  Return a 'loose' lxml element having the tag specified by `nsptag_str`.

    The tag in `nsptag_str` must contain the standard namespace prefix, e.g. `a:tbl`.
    The resulting element is an instance of the custom element class for this tag name
    if one is defined. A dictionary of attribute values may be provided as `attrs`; they
    are set if present. All namespaces defined in the dict `nsdecls` are declared in the
    element using the key as the prefix and the value as the namespace name. If
    `nsdecls` is not provided, a single namespace declaration is added based on the
    prefix on `nsptag_str`.
    N)Úattribr	   )r   r	   r   ÚmakeelementÚ
clark_name)r"   r#   r%   Únsptagr   r   r   ÚOxmlElement,   s   r+   )r   r   r   r   )r   r   r   r   )NN)r"   r   r#   r$   r%   r$   r   r&   )Ú__doc__Ú
__future__r   Útypingr   r   r   r   Úlxmlr   Údocx.oxml.nsr   r	   Údocx.oxml.xmlchemyr
   ÚElementNamespaceClassLookupr   Ú	XMLParserr   Úset_element_class_lookupr   r!   r+   r   r   r   r   Ú<module>   s   


	ý