B
    ÔùÓ`�  ã               @   sV   d Z ddlZddlmZ ddlmZmZ ddlmZ deej	e
 eejdœd	d
„ZdS )zJA Public API to open configuration files by detecting type automatically.
é    Né   )ÚPathOrIOInfoT)ÚfindÚMaybeParserTé   )ÚParserT)ÚpathÚmodeÚ	ac_parserÚreturnc             K   s:   t | |d�}|dk	r,| d¡r,|j| f|ŽS |j| f|ŽS )aÕ  
    Open given configuration file 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forced_typeNÚw)r   Ú
startswithZwopenZropen)r   r	   r
   ÚoptionsZpsr© r   ú7/tmp/pip-unpacked-wheel-bpftjxoo/anyconfig/api/_open.pyÚopen   s    r   )NN)Ú__doc__ÚtypingÚcommonr   Úparsersr   r   Z	datatypesr   ÚOptionalÚstrZIOr   r   r   r   r   Ú<module>   s    