B
    ~‹dw  ã               @   s"   d Z ddlZdZdZddd„ZdS )	zEnvironment utilities for GWpy
é    Nz(Duncan Macleod <duncan.macleod@ligo.org>)Ú1ÚyÚyesÚtrueFc             C   s,   yt j|   ¡ tkS  tk
r&   |S X dS )a~  Parse an environment variable as a boolean switch

    `True` is returned if the variable value matches one of the following:

    - ``'1'``
    - ``'y'``
    - ``'yes'``
    - ``'true'``

    The match is case-insensitive (so ``'Yes'`` will match as `True`)

    Parameters
    ----------
    key : `str`
        the name of the environment variable to find

    default : `bool`
        the default return value if the key is not found

    Returns
    -------
    True
        if the environment variable matches as 'yes' or similar
    False
        otherwise

    Examples
    --------
    >>> import os
    >>> from gwpy.utils.env import bool_env
    >>> os.environ['GWPY_VALUE'] = 'yes'
    >>> print(bool_env('GWPY_VALUE'))
    True
    >>> os.environ['GWPY_VALUE'] = 'something else'
    >>> print(bool_env('GWPY_VALUE'))
    False
    >>> print(bool_env('GWPY_VALUE2'))
    False
    N)ÚosÚenvironÚlowerÚTRUEÚKeyError)ÚkeyÚdefault© r   ú[/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/gwpy/utils/env.pyÚbool_env"   s    (r   )F)Ú__doc__r   Ú
__author__r	   r   r   r   r   r   Ú<module>   s   