
    dhh                     z    S r SSKrSSKJr  SSKJrJrJrJ	r	J
r
   " S S\5      r SS\	\\4   S\S	\\   4S
 jjrg)zDocument loader helpers.    N)Path)List
NamedTupleOptionalUnioncastc                   H    \ rS rSr% Sr\\   \S'    \\S'    \\   \S'   Sr	g)FileEncoding   z File encoding as the NamedTuple.encoding
confidencelanguage N)
__name__
__module____qualname____firstlineno____doc__r   str__annotations__float__static_attributes__r       d/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/document_loaders/helpers.pyr
   r
      s(    *sm#)sm#r   r
   	file_pathtimeoutreturnc                   ^ SSK m[        U 5      n S[        S[        [           4U4S jjn[        R
                  R                  5        nUR                  X 5      n UR                  US9n SSS5        [        S W 5       5      (       a  [        S	U  35      eU Vs/ sH  ofS
   c  M
  [        S0 UD6PM     sn$ ! [        R
                  R                   a    [        SU  35      ef = f! , (       d  f       N= fs  snf )a  Try to detect the file encoding.

Returns a list of `FileEncoding` tuples with the detected encodings ordered
by confidence.

Args:
    file_path: The path to the file to detect the encoding for.
    timeout: The timeout in seconds for the encoding detection.
r   Nr   r   c                    > [        U S5       nUR                  5       nS S S 5        [        [        [           TR                  W5      5      $ ! , (       d  f       N4= f)Nrb)openreadr   r   dict
detect_all)r   frawdatachardets      r   read_and_detect.detect_file_encodings.<locals>.read_and_detect#   sD    )T"affhG #DJ 2 27 ;<< #"s   A
A)r   z-Timeout reached while detecting encoding for c              3   ,   #    U H  oS    SL v   M     g7f)r   Nr   ).0r   s     r   	<genexpr>(detect_file_encodings.<locals>.<genexpr>1   s     
B	HJ4'	s   zCould not detect encoding for r   r   )r'   r   r   r#   
concurrentfuturesThreadPoolExecutorsubmitresultTimeoutErrorallRuntimeErrorr
   )r   r   r(   executorfuture	encodingsencr'   s          @r   detect_file_encodingsr:      s     II=3 =4: =
 
			.	.	0H<	g6I 
1 
B	
BBB;I;GHH+4T9CJL39TT !!.. 	?	{K 		 
1	0 Us*   
C,B<C=*C=<-C))C,,
C:)   )r   concurrent.futuresr.   pathlibr   typingr   r   r   r   r   r
   r   intr:   r   r   r   <module>r@      sT       : :$: $ 12 US$Y U*- U	, Ur   