
    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 )zOProvides the PackURI value type and 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d            Ze
dd            Ze
dd            ZddZe
dd            ZdS )PackURIzProxy for a pack URI (partname).

    Provides utility properties the baseURI and the filename slice. Behaves as |str| otherwise.
    z([a-zA-Z]+)([0-9][0-9]*)?pack_uri_strstrc                    |d         dk    st          dt          |                     t                              | |          S )Nr   /z#PackURI must begin with slash, got )
ValueErrorreprr   __new__)clsr   s     h/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/pptx/opc/packuri.pyr   zPackURI.__new__   sD    A#%%W4CUCUWWXXX{{3---    baseURIrelative_refreturnc                r    t          j        | |          }t          j        |          }t          |          S )zSConstruct an absolute pack URI 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 "/", the 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 `"/ppt/slides/slide1.xml"`. Note the leading 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.filename1   r   r   
int | Nonec                    | j         }|sdS t          j        |          d         }| j                            |          }|dS |                    d          r"t          |                    d                    S dS )zOptional int partname index.

        Value is an integer for an "array" 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.

        This is 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)   )r   r   r   r   )r   r   )__name__
__module____qualname____doc__recompiler,   r   staticmethodr   propertyr   r&   r(   r1   r4   r   r;   r3   r   r   r   r   	   sB        
 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_URIr3   r   r   <module>rG      s    U U " " " " " "     				`% `% `% `% `%c `% `% `%F gcllG233   r   