a
    �Ï?eØ  ã                   @   s@   d Z ddlZddlZejedœdd„Zd
ejeedœdd	„ZdS )z0Utility funtions to process file and file paths.é    N)ÚobjÚreturnc                 C   s   t t| ddƒƒS )zCTest if given object ``obj`` is an IO stream, file or -like object.ÚreadF)ÚcallableÚgetattr)r   © r   úX/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/anyconfig/utils/files.pyÚis_io_stream
   s    r	   F)ÚstrmÚsafer   c              	   C   s^   t | ƒs|std| ›�ƒ‚t| ddƒ}|durZztt |¡ ¡ ƒW S  ttfyX   Y n0 dS )zÇTry to get file path from given file or file-like object 'strm'.

    :param strm: A file or file-like object might have its file path info
    :return: file path or None
    :raises: ValueError
    z'It does not look a file[-like] object: ÚnameNÚ )r	   Ú
ValueErrorr   ÚstrÚpathlibÚPathÚresolveÚ	TypeError)r
   r   Úpathr   r   r   Úget_path_from_stream   s    r   )F)	Ú__doc__r   ÚtypingÚAnyÚboolr	   ÚIOr   r   r   r   r   r   Ú<module>   s   