a
    ¡˜ëjc
  ã                   @  sŽ   d dl mZ d dlZd dlZd dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZmZ d dlmZ d dlmZ dd	d
d	d	dddœdd„ZdS )é    )ÚannotationsN)ÚIOÚAnyÚOptional)ÚElement)ÚFileType)Úconvert_office_docÚexactly_one)Úget_last_modified_date)Úpartition_pptxzOptional[str]zOptional[IO[bytes]]r   zlist[Element])ÚfilenameÚfileÚmetadata_filenameÚmetadata_last_modifiedÚkwargsÚreturnc              	   K  sF  t | |d� | rt| ƒnd}t ¡ �ò}| rHtj | ¡sštd| › d�ƒ‚nR|sPJ ‚tj |d¡}t	|dƒ�}| 
| ¡ ¡ W d  ƒ n1 sŒ0    Y  |} tj tj | ¡¡\}	}
tj |
¡\}}	t| |ddd	� tj ||› d
�¡}tf ||pò| tj|pü|dœ|¤Ž}W d  ƒ n1 �s0    Y  |�rB|D ]}||j_�q2|S )aã  Partitions Microsoft PowerPoint Documents in .ppt format into their document elements.

    Parameters
    ----------
    filename
        A string defining the target filename path.
    file
        A file-like object using "rb" mode --> open(filename, "rb").
    metadata_last_modified
        The last modified date for the document.

    Note that all arguments valid on `partition_pptx()` are also valid here and will be passed
    along to the `partition_pptx()` function.
    )r   r   Nz	The file z does not exist.Útmp_fileÚwbZpptxzImpress MS PowerPoint 2007 XML)Ztarget_formatZtarget_filterz.pptx)r   r   Zmetadata_file_typer   )r	   r
   ÚtempfileÚTemporaryDirectoryÚosÚpathÚexistsÚ
ValueErrorÚjoinÚopenÚwriteÚreadÚsplitÚabspathÚsplitextr   r   r   ZPPTÚmetadatar   )r   r   r   r   r   Zlast_modifiedZtmpdirZtmp_file_pathr   Ú_Zfilename_no_pathÚbase_filenameZpptx_filenameÚelementsÚelement© r&   úY/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/unstructured/partition/ppt.pyÚpartition_ppt   s@    
,üüû&	r(   )NNNN)Ú
__future__r   r   r   Útypingr   r   r   Zunstructured.documents.elementsr   Zunstructured.file_utils.modelr   Z$unstructured.partition.common.commonr   r	   Z&unstructured.partition.common.metadatar
   Zunstructured.partition.pptxr   r(   r&   r&   r&   r'   Ú<module>   s       ü