o
    i                     @  s8   d Z ddlmZ ddlZG dd deZddddZdS )zrEnvironment variable helpers.

This module provides small, centralized parsing helpers for environment variables.
    )annotationsNc                      s"   e Zd ZdZd fddZ  ZS )	InvalidEnvVarValueErrorz;Raised when an environment variable value cannot be parsed.namestrvalueexpectedc              	     s6   t  d|d|d| d || _|| _|| _dS )z&Initialize an InvalidEnvVarValueError.zInvalid value for env var z: z. Expected .N)super__init__r   r   r   )selfr   r   r   	__class__ E/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/utils/env.pyr
      s    
z InvalidEnvVarValueError.__init__)r   r   r   r   r   r   )__name__
__module____qualname____doc__r
   __classcell__r   r   r   r   r      s    r   Fr   r   defaultboolreturnc                 C  sH   t | }|du r|S |  }|dv rdS |dv rdS t| |dd)a  Interpret an environment variable as a boolean.

    - If the variable is **not set**, returns `default`.
    - If the variable is set to a recognized boolean string, returns the parsed value.
    - Otherwise, raises `InvalidEnvVarValueError`.

    Recognized values (case-insensitive, whitespace ignored):
    - Truthy: "1", "true", "yes", "y", "on"
    - Falsy:  "0", "false", "no", "n", "off", ""
    N>   1yonyestrueT>    0nnoofffalseFztrue or false)r   r   r   )osgetenvstriplowerr   )r   r   rawvalr   r   r   
env_truthy   s   
r)   )F)r   r   r   r   r   r   )r   
__future__r   r#   
ValueErrorr   r)   r   r   r   r   <module>   s
   