
    j|                     b    d Z ddlZddlZ G d de          Z ed          Z ed          ZdS )z_Provides the PackURI value type.

Also some useful known pack URI strings such as PACKAGE_URI.
    Nc                       e Zd ZdZ ej        d          Zd Zed             Z	e
d             Ze
d             Ze
d             Ze
d             Ze
d	             Zd
 Ze
d             ZdS )PackURIz|Provides access to pack URI components such as the baseURI and the filename
    slice.

    Behaves as |str| otherwise.
    z([a-zA-Z]+)([1-9][0-9]*)?c                 x    |d         dk    rd}t          ||z            t                              | |          S )Nr   /z'PackURI must begin with slash, got '%s')
ValueErrorstr__new__)clspack_uri_strtmpls      Z/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/docx/opc/packuri.pyr	   zPackURI.__new__   s=    ?c!!<DTL0111{{3---    c                 r    t          j        | |          }t          j        |          }t          |          S )zyReturn a |PackURI| instance containing the absolute pack URI formed by
        translating `relative_ref` onto `baseURI`.)	posixpathjoinabspathr   )baseURIrelative_ref
joined_uriabs_uris       r   from_rel_refzPackURI.from_rel_ref   s3     ^G\::
#J//wr   c                 6    t          j        |           d         S )zThe base URI of this pack URI, the directory portion, roughly speaking.

        E.g. ``'/ppt/slides'`` for ``'/ppt/slides/slide1.xml'``. For the package pseudo-
        partname '/', baseURI is '/'.
        r   r   splitselfs    r   r   zPackURI.baseURI!        t$$Q''r   c                 x    t          j        |           d         }|                    d          r
|dd         n|S )zThe extension portion of this pack URI, e.g. ``'xml'`` for
        ``'/word/document.xml'``.

        Note the period is not included.
           .N)r   splitext
startswith)r   raw_exts     r   extzPackURI.ext*   s>     $T**1-%0055Bwqrr{{7Br   c                 6    t          j        |           d         S )zThe "filename" portion of this pack URI, e.g. ``'slide1.xml'`` for
        ``'/ppt/slides/slide1.xml'``.

        For the package pseudo-partname '/', filename is ''.
        r   r   r   s    r   filenamezPackURI.filename5   r   r   c                     | j         }|sdS t          j        |          d         }| j                            |          }|dS |                    d          r"t          |                    d                    S dS )zReturn partname index as integer for tuple partname or None for singleton
        partname, e.g. ``21`` for ``'/ppt/slides/slide21.xml'`` and |None| for
        ``'/ppt/presentation.xml'``.Nr      )r&   r   r!   _filename_rematchgroupint)r   r&   	name_partr*   s       r   idxzPackURI.idx>   s|    
 = 	4&x003	!''	22=4;;q>> 	'u{{1~~&&&tr   c                     | dd         S )zThe pack URI with the leading slash stripped off, the form used as the Zip
        file membername for the package item.

        Returns '' for the package pseudo-partname '/'.
        r   N r   s    r   
membernamezPackURI.membernameN   s     ABBxr   c                 L    |dk    r
| dd         nt          j        | |          S )zReturn string containing relative reference to package item from `baseURI`.

        E.g. PackURI('/ppt/slideLayouts/slideLayout1.xml') would return
        '../slideLayouts/slideLayout1.xml' for baseURI '/ppt/slides'.
        r   r   N)r   relpath)r   r   s     r   r   zPackURI.relative_refW   s+     #c>>tABBxxy/@w/O/OOr   c                 j    d| j         z  }t          j        | j        d|          }t	          |          S )zThe pack URI of the .rels part corresponding to the current pack URI.

        Only produces sensible output if the pack URI is a partname or the package
        pseudo-partname '/'.
        z%s.rels_rels)r&   r   r   r   r   )r   rels_filenamerels_uri_strs      r   rels_urizPackURI.rels_uria   s3     "DM1 ~dlG]KK|$$$r   N)__name__
__module____qualname____doc__recompiler)   r	   staticmethodr   propertyr   r$   r&   r.   r1   r   r8   r0   r   r   r   r   
   s         2:9::L. . .     \  ( ( X( C C XC ( ( X(   X   XP P P % % X% % %r   r   r   z/[Content_Types].xml)r<   r   r=   r   r   PACKAGE_URICONTENT_TYPES_URIr0   r   r   <module>rC      s    
     				`% `% `% `% `%c `% `% `%F gcllG233   r   