U
    ZfC                     @   sV   d dl Z d dlZddlmZ ddlmZ dd Ze ZdddZdd	d
Z	dd Z
dS )    N   )
exceptionsAttributeDictc                   C   s   t dd dD S )Nc              
   S   s$   i | ]}|t |t | qS  )osgetenvlower).0varr   r   1/tmp/pip-unpacked-wheel-47crqvv_/dash/_configs.py
<dictcomp>   s    z&load_dash_env_vars.<locals>.<dictcomp>)DASH_APP_NAMEZDASH_URL_BASE_PATHNAMEZDASH_ROUTES_PATHNAME_PREFIXZDASH_REQUESTS_PATHNAME_PREFIXZ!DASH_SUPPRESS_CALLBACK_EXCEPTIONSZDASH_ASSETS_EXTERNAL_PATHDASH_INCLUDE_ASSETS_FILESZDASH_COMPONENTS_CACHE_MAX_AGEr   ZDASH_SERVE_DEV_BUNDLESZ
DASH_DEBUGZDASH_UIZDASH_PROPS_CHECKZDASH_HOT_RELOADZDASH_HOT_RELOAD_INTERVALZDASH_HOT_RELOAD_WATCH_INTERVALZDASH_HOT_RELOAD_MAX_RETRYZDASH_SILENCE_ROUTES_LOGGINGZDASH_PRUNE_ERRORSZDASH_COMPRESSZHOSTZPORTr   r   r   r   r   load_dash_env_vars	   s
    r   c                 C   sJ   |dk	r|S t  d|   }|dkr.|S | dkrF| dkS |S )zeConsolidate the config with priority from high to low provided init
    value > OS environ > default.NZDASH_>   falsetruer   )r   getupperr	   )namevaldefaultenvr   r   r   get_combined_config,   s    r   c                 C   s   d}t d| } t d|}t d|}| d k	rB|d k	rBt|d| d k	rb|d k	rbt|d| d k	rx|d krx| }n|d krd}|dstd|dstd	t j}|s|rd| | }n|d kr|}|dstd
| ||fS )Na^  
    {} This is ambiguous.
    To fix this, set `routes_pathname_prefix` instead of `url_base_pathname`.

    Note that `requests_pathname_prefix` is the prefix for the AJAX calls that
    originate from the client (the web browser) and `routes_pathname_prefix` is
    the prefix for the API routes on the backend (this flask server).
    `url_base_pathname` will set `requests_pathname_prefix` and
    `routes_pathname_prefix` to the same value.
    If you need these to be different values then you should set
    `requests_pathname_prefix` and `routes_pathname_prefix`,
    not `url_base_pathname`.
    url_base_pathnameroutes_pathname_prefixrequests_pathname_prefixz@You supplied `url_base_pathname` and `requests_pathname_prefix`.z>You supplied `url_base_pathname` and `routes_pathname_prefix`./z0`routes_pathname_prefix` needs to start with `/`z.`routes_pathname_prefix` needs to end with `/`z2`requests_pathname_prefix` needs to start with `/`)r   r   InvalidConfigformat
startswithendswithr   r   )r   r   r   Z_pathname_config_error_messageZapp_namer   r   r   pathname_configs:   sT    
  



r"   c                 C   sX   |sd S t |dk}tjtj| |}|s2|rTtj|sTd| d}t	||S )NZpagesz
        A folder called `z` does not exist. If a folder for pages is not
        required in your application, set `pages_folder=""`. For example:
        `app = Dash(__name__,  pages_folder="")`
        )
strr   pathjoinflaskZhelpersZget_root_pathisdirr   r   )r   Zpages_folderZ	use_pagesZis_custom_folderZpages_folder_path	error_msgr   r   r   pages_folder_config}   s    
r)   )N)NNN)r   r&    r   _utilsr   r   ZDASH_ENV_VARSr   r"   r)   r   r   r   r   <module>   s    
     
C