a
    �Ï?ey  ã                   @   sV   d Z ddlZddlZddlmZmZ ddlmZ d
ejej	e
 ejejdœdd	„ZdS )z:A API to open files by detecting those type automatically.é    Né   )ÚioinfoÚparsersé   )ÚParserT)ÚpathÚmodeÚ	ac_parserÚreturnc                 K   sŽ   | st d| ›�ƒ‚t | ¡}t |¡rFt d|›�¡ t tj|j	¡S t
j||d�}|durz| d¡rz|j|jfi |¤ŽS |j|jfi |¤ŽS )aË  Open given file ``path`` with appropriate open flag.

    :param path: Configuration file path
    :param mode:
        Can be 'r' and 'rb' for reading (default) or 'w', 'wb' for writing.
        Please note that even if you specify 'r' or 'w', it will be changed to
        'rb' or 'wb' if selected backend, xml and configobj for example, for
        given config file prefer that.
    :param options:
        Optional keyword arguments passed to the internal file opening APIs of
        each backends such like 'buffering' optional parameter passed to
        builtin 'open' function.

    :return: A file object or None on any errors
    :raises: ValueError, UnknownProcessorTypeError, UnknownFileTypeError
    zInvalid argument, path: zLooks already opened stream: )Zforced_typeNÚw)Ú
ValueErrorr   ÚmakeÚ	is_streamÚwarningsÚwarnÚtypingÚcastÚIOÚsrcr   ÚfindÚ
startswithZwopenr   Zropen)r   r   r	   ÚoptionsZioiZpsr© r   úV/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/anyconfig/api/_open.pyÚopen   s    

r   )NN)Ú__doc__r   r   Ú r   r   Z	datatypesr   ZPathOrIOInfoTÚOptionalÚstrZMaybeParserTr   r   r   r   r   r   Ú<module>   s     þý