
    :QgY
                    ~    d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	  e	dg      d	d       Z
	 d
	 	 	 	 	 	 	 ddZy)    )annotationsN)IO)exactly_one)requires_dependenciespypandocc                   ddl }	 |j                  | ||      }|S # t        $ r}d| }t        |      d}~wt        $ rJ}|j	                         \  }}|dk(  r||vrd}	nd}	| d|	 d	|j                          d
}t        |      d}~ww xY w)z@Uses pandoc to convert the source document to a raw text string.r   N)formatzError converting the file to text. Ensure you have the pandoc package installed on your system. Installation instructions are available at https://pandoc.org/installing.html. The original exception text was:
rtfzSupport for RTF files is not available in the current pandoc installation. It was introduced in pandoc 2.14.2.
Reference: https://pandoc.org/releases.html#pandoc-2.14.2-2021-08-21 z

z

Current version of pandoc: z
Make sure you have the right version installed in your system. Please follow the pandoc installation instructions in README.md to install the right version.)r   convert_fileFileNotFoundErrorRuntimeErrorget_pandoc_formatsget_pandoc_version)
filenamesource_formattarget_formatr   texterrmsgsupported_source_formats_additional_infos
             d/var/www/html/answerous/venv/lib/python3.12/site-packages/unstructured/file_utils/file_conversion.pyconvert_file_to_textr      s      $$X}]$S8 K7  %VVYUZ\ 	
  $$  &.&A&A&C# !E!m;S&SW  !O e4( )**2*E*E*G)H I[[ 	 3% s    	B5BABBc                z   t        ||       |t        j                         5 }t        j                  j                  |d|        }t        |d      5 }|j                  |j                                ddd       t        || d      cddd       S |J t        || d      S # 1 sw Y   2xY w# 1 sw Y   'xY w)znConverts a document to HTML raw text.

    Enables the doucment to be processed using `partition_html()`.
    )r   fileNz	tmp_file.wbhtml)r   r   r   )
r   tempfileTemporaryDirectoryospathjoinopenwritereadr   )r   r   r   temp_dir_pathtmp_file_pathtmp_files         r   &convert_file_to_html_text_using_pandocr+   0   s     -((* 	mGGLL)M?8STMmT* ,htyy{+,'&mSY		 	 f , ,	 	s#   0B1 B%4B1%B.	*B11B:)r   strr   r,   r   r,   returnr,   )NN)r   r,   r   z
str | Noner   zIO[bytes] | Noner-   r,   )
__future__r   r"   r    typingr   $unstructured.partition.common.commonr   unstructured.utilsr   r   r+        r   <module>r4      s_    " 	   < 4 
|$! %!J OS",;Kr3   