o
    7 h                     @  sD   d Z ddlmZ ddlZddlZG d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                   @  s   e Zd ZdZedZdddZedd
dZ	e
dddZe
dddZe
dddZe
dddZe
dddZd ddZe
d!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                 C  s*   |d dkst dt| t| |S )Nr   /z#PackURI must begin with slash, got )
ValueErrorreprr   __new__)clsr    r   X/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/pptx/opc/packuri.pyr	      s   zPackURI.__new__baseURIrelative_refreturnc                 C  s   t | |}t |}t|S )zSConstruct an absolute pack URI formed by translating `relative_ref` onto `baseURI`.)	posixpathjoinabspathr   )r   r   Z
joined_uriZabs_urir   r   r   from_rel_ref   s   
zPackURI.from_rel_refc                 C     t | 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selfr   r   r   r         zPackURI.baseURIc                 C  s(   t | d }|dr|dd S |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   Zraw_extr   r   r   ext'   s   zPackURI.extc                 C  r   )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   r   r   r   filename1   r   zPackURI.filename
int | Nonec                 C  sP   | j }|sdS t|d }| j|}|du r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   Z	name_partr#   r   r   r   idx;   s   
zPackURI.idxc                 C  s   | 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   Nr   r   r   r   r   
membernameM   s   zPackURI.membernamec                 C  s    |dkr
| dd S t | |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   r   r   r   r   V   s    zPackURI.relative_refc                 C  s"   d| j  }t| 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   Zrels_filenameZrels_uri_strr   r   r   rels_uri`   s   
zPackURI.rels_uriN)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   r&   r'   r   r*   r   r   r   r   r   	   s&    

			

r   r   z/[Content_Types].xml)	r.   
__future__r   r   r/   r   r   PACKAGE_URICONTENT_TYPES_URIr   r   r   r   <module>   s    c