o
    5tiK                     @   s   d Z ddlZddlZddlmZmZmZ ddlmZm	Z	 ddl
mZ de	eeef defd	d
Zdee dee fddZdee fddZdS )zA
.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
    N)EBADFENOENTENOTDIR)OptionalUnion   )is_binary_ext_path	file_pathreturnc              
   C   s`   z
t t | jW S  ty& } z|jtttfvr W Y d }~dS d }~w t	y/   Y dS w )NF)
statS_ISFIFOosst_modeOSErrorerrnor   r   r   
ValueError)r	   e r   F/home/ubuntu/.local/lib/python3.10/site-packages/mbstrdecoder/_func.pyis_fifo   s   r   namec                 C   s   | sd S |   ddS )N-_)lowerreplace)r   r   r   r   to_codec_name   s   r   c                 C   s   ddl m} tj| rt| st| rd S | }d}zAz+t| dd}	 ||}|s-n
|	| |j
r6nq%W d    n1 sAw   Y  W n tyV   Y W |  d S w W |  n|  w t|jdS )Nr   )UniversalDetectori   rb)modeTencoding)chardet.universaldetectorr   r   pathisfiler   r   openreadfeeddoner   closer   resultget)r	   r   detector	READ_SIZEfbinaryr   r   r   detect_file_encoding    s2   

	r.   )__doc__r   r   r   r   r   r   typingr   r   _binary_ext_checkerr   intbytesstrboolr   r   r.   r   r   r   r   <module>   s    