a
    ¡˜ëjÏ  ã                	   @   sˆ   d dl mZmZ d dlmZ d dlmZ d dlmZ de	e
dœdd„Zde	e
e
e
e
eee	  d
œdd„Zdd„ Zde
e
e
dœdd„Zd	S )é    )ÚListÚOptional)Úlogger)ÚPartitionStrategy)Údependency_existsF)ÚstrategyÚis_imagec                 C   sD   t jt jt jt jg}| |vr*t| › d�ƒ‚| t jkr@|r@tdƒ‚dS )z?Determines if the strategy is valid for the specified filetype.z is not a valid strategy.z3The fast strategy is not available for image files.N)r   ÚAUTOÚFASTÚOCR_ONLYÚHI_RESÚ
ValueError)r   r   Zvalid_strategies© r   ú`/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/unstructured/partition/strategies.pyÚvalidate_strategy   s    ür   N)r   r   Úpdf_text_extractableÚinfer_table_structureÚextract_images_in_pdfÚextract_image_block_typesc           	      C   sÚ   t dƒ}t dƒ}| tjkr@|p$t|ƒ}|r2tƒ } nt|||d�} t| | | gƒr\tdƒ‚| tjkrš|sšt	 
d¡ |rˆt	 
d¡ tjS t	 
d¡ tjS n<| tjkrÖ|sÖt	 
d¡ |rÆt	 
d¡ tjS t	 
d	¡ tjS | S )
zˆDetermines what strategy to use for processing PDFs or images, accounting for fallback
    logic if some dependencies are not available.Zunstructured_pytesseractZunstructured_inference©r   r   Úextract_elementzäunstructured_inference is not installed, pytesseract is not installed and the text of the PDF is not extractable. To process this file, install unstructured_inference, install pytesseract, or remove copy protection from the PDF.z‰unstructured_inference is not installed. Cannot use the hi_res partitioning strategy. Falling back to partitioning with another strategy.z+Falling back to partitioning with ocr_only.z'Falling back to partitioning with fast.z€pytesseract is not installed. Cannot use the ocr_only partitioning strategy. Falling back to partitioning with another strategy.z)Falling back to partitioning with hi_res.)r   r   r	   ÚboolÚ_determine_image_auto_strategyÚ_determine_pdf_auto_strategyÚallr   r   r   Úwarningr   r
   )	r   r   r   r   r   r   Zpytesseract_installedZ unstructured_inference_installedr   r   r   r   Údetermine_pdf_or_image_strategy   sH    

ýÿÿÿ

ÿ

r   c                   C   s   t jS )zWIf "auto" is passed in as the strategy, determines what strategy to use
    for images.)r   r   r   r   r   r   r   W   s    r   r   c                 C   s"   |s|rt jS | rt jS t jS dS )zUIf "auto" is passed in as the strategy, determines what strategy to use
    for PDFs.N)r   r   r
   r   r   r   r   r   r   ^   s
    	r   )F)FFFFN)FFF)Útypingr   r   Zunstructured.loggerr   Z&unstructured.partition.utils.constantsr   Zunstructured.utilsr   Ústrr   r   r   r   r   r   r   r   r   Ú<module>   s4        ú
ú?   ýý