
    hi                    n    d Z ddlm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.
    )annotationsNc                      e Zd ZdZ ej        d          ZddZedd	            Z	e
dd
            Ze
dd            Ze
d             Ze
d             Ze
d             ZddZe
d             ZdS )PackURIzxProvides 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]*)?pack_uri_strstrc                x    |d         dk    rd}t          ||z            t                              | |          S )Nr   /z'PackURI must begin with slash, got '%s')
ValueErrorr   __new__)clsr   tmpls      h/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/docx/opc/packuri.pyr   zPackURI.__new__   s=    ?c!!<DTL0111{{3---    baseURIrelative_refreturnc                r    t          j        | |          }t          j        |          }t          |          S )zIThe absolute PackURI formed by translating `relative_ref` onto `baseURI`.)	posixpathjoinabspathr   )r   r   
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.filename4   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.membernameM   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_refV   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_uri`   s3     "DM1 ~dlG]KK|$$$r   N)r   r   )r   r   r   r   r   r   )r   r   )r   r   )__name__
__module____qualname____doc__recompiler+   r   staticmethodr   propertyr   r&   r(   r0   r3   r   r:   r2   r   r   r   r      s.        
 2:9::L. . . .       \  ( ( ( X( C C C XC ( ( X(   X   XP P P P % % X% % %r   r   r	   z/[Content_Types].xml)	r>   
__future__r   r   r?   r   r   PACKAGE_URICONTENT_TYPES_URIr2   r   r   <module>rF      s    
 # " " " " "     				]% ]% ]% ]% ]%c ]% ]% ]%@ gcllG233   r   