a
    ]øjÃ  ã                   @  s˜   d Z ddlmZ ddlmZ dddddd	d
ddddddddddœZdd„ e ¡ D ƒZG dd„ deƒZ	dddœdd„Z
dddœdd „Zddd!œd"d#„Zd$S )%zNamespace-related objects.é    )Úannotations)ÚDictz5http://schemas.openxmlformats.org/drawingml/2006/mainz6http://schemas.openxmlformats.org/drawingml/2006/chartzGhttp://schemas.openxmlformats.org/package/2006/metadata/core-propertiesz http://purl.org/dc/elements/1.1/zhttp://purl.org/dc/dcmitype/zhttp://purl.org/dc/terms/z8http://schemas.openxmlformats.org/drawingml/2006/diagramz:http://schemas.openxmlformats.org/officeDocument/2006/mathz8http://schemas.openxmlformats.org/drawingml/2006/picturezChttp://schemas.openxmlformats.org/officeDocument/2006/relationshipsz9http://schemas.openxmlformats.org/schemaLibrary/2006/mainz<http://schemas.openxmlformats.org/wordprocessingml/2006/mainz4http://schemas.microsoft.com/office/word/2010/wordmlzFhttp://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawingz$http://www.w3.org/XML/1998/namespacez)http://www.w3.org/2001/XMLSchema-instance)ÚaÚcÚcpZdcZdcmitypeZdctermsZdgmÚmZpicÚrÚslÚwZw14ZwpÚxmlZxsic                 C  s   i | ]\}}||“qS © r   )Ú.0ÚkeyÚvaluer   r   úH/var/www/html/assistant/venv/lib/python3.9/site-packages/docx/oxml/ns.pyÚ
<dictcomp>   ó    r   c                      s¢   e Zd ZdZddœ‡ fdd„Zddœdd„Zeddœd	d
„ƒZedd dœdd„ƒZ	eddœdd„ƒZ
eddœdd„ƒZeddœdd„ƒZeddœdd„ƒZ‡  ZS )ÚNamespacePrefixedTagzNValue object that knows the semantics of an XML tag having a namespace prefix.Ústr)Únstagc                   s   t t| ƒ | |¡S )N)Úsuperr   Ú__new__)Úclsr   ©Ú	__class__r   r   r       s    zNamespacePrefixedTag.__new__c                 C  s"   |  d¡\| _| _t| j | _d S )Nú:)ÚsplitÚ_pfxÚ_local_partÚnsmapÚ_ns_uri)Úselfr   r   r   r   Ú__init__#   s    zNamespacePrefixedTag.__init__)Úreturnc                 C  s   d| j | jf S )Nú{%s}%s)r    r   ©r!   r   r   r   Ú
clark_name'   s    zNamespacePrefixedTag.clark_name)r&   r#   c                 C  s.   |dd …   d¡\}}dt| |f }| |ƒS )Né   Ú}z%s:%s)r   Úpfxmap)r   r&   ÚnsuriZ
local_namer   r   r   r   Úfrom_clark_name+   s    z$NamespacePrefixedTag.from_clark_namec                 C  s   | j S )z[The local part of this tag.

        E.g. "foobar" is returned for tag "f:foobar".
        )r   r%   r   r   r   Ú
local_part1   s    zNamespacePrefixedTag.local_partúDict[str, str]c                 C  s   | j | jiS )z¼Single-member dict mapping prefix of this tag to it's namespace name.

        Example: `{"f": "http://foo/bar"}`. This is handy for passing to xpath calls
        and other uses.
        )r   r    r%   r   r   r   r   9   s    zNamespacePrefixedTag.nsmapc                 C  s   | j S )zeThe namespace-prefix for this tag.

        For example, "f" is returned for tag "f:foobar".
        )r   r%   r   r   r   ÚnspfxB   s    zNamespacePrefixedTag.nspfxc                 C  s   | j S )z±The namespace URI for this tag.

        For example, "http://foo/bar" would be returned for tag "f:foobar" if the "f"
        prefix maps to "http://foo/bar" in nsmap.
        )r    r%   r   r   r   r*   J   s    zNamespacePrefixedTag.nsuri)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r"   Úpropertyr&   Úclassmethodr+   r,   r   r.   r*   Ú__classcell__r   r   r   r   r      s   r   r   )Úprefixesr#   c                  G  s   d  dd„ | D ƒ¡S )z—Namespace declaration including each namespace-prefix in `prefixes`.

    Handy for adding required namespace declarations to a tree root element.
    ú c                 S  s   g | ]}d |t | f ‘qS )zxmlns:%s="%s"©r   ©r   Úpfxr   r   r   Ú
<listcomp>Y   r   znsdecls.<locals>.<listcomp>)Újoin)r6   r   r   r   ÚnsdeclsT   s    r=   r-   )Únspfxsr#   c                  G  s   dd„ | D ƒS )z“Subset namespace-prefix mappings specified by *nspfxs*.

    Any number of namespace prefixes can be supplied, e.g. namespaces("a", "r", "p").
    c                 S  s   i | ]}|t | “qS r   r8   r9   r   r   r   r   a   r   znspfxmap.<locals>.<dictcomp>r   )r>   r   r   r   Únspfxmap\   s    r?   )Útagr#   c                 C  s"   |   d¡\}}t| }d||f S )a  Stands for "qualified name".

    This utility function converts a familiar namespace-prefixed tag name like "w:p"
    into a Clark-notation qualified tag name for lxml. For example, `qn("w:p")` returns
    "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}p".
    r   r$   )r   r   )r@   ÚprefixZtagrootÚurir   r   r   Úqnd   s    rC   N)r2   Ú
__future__r   Útypingr   r   Úitemsr)   r   r   r=   r?   rC   r   r   r   r   Ú<module>   s0   ð7