
    Mf                         d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ d Zd	 Zd
 Zd Zd Zd Zd Zd ZddZddZd Zd Zd Zd Zd Zd ZdS )a[  
Utility functions

Copyright (c) 2018 Gibbs Consulting and others - see CONTRIBUTIONS.md

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

    N)
get_module)settings)cache)import_string)DjangoPlotlyJSONEncoderc                  N    	 t           j        } n# t          $ r d } Y nw xY w| r| ni S N)r   PLOTLY_DASHAttributeError)the_settingss    V/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/django_plotly_dash/util.py_get_settingsr   '   sF    +    (/<<R/s    c                  F    t                                          dd          S )z2Return the endpoint for pipe websocket connectionsws_routezdpd/ws/channelr   get     r   pipe_ws_endpoint_namer   /   s    ??z+;<<<r   c                  F    t                                          dd          S )zJReturn the root of the http endpoint for direct insertion of pipe messages
http_routez	dpd/viewsr   r   r   r   dpd_http_endpoint_rootr   3   s    ??|[999r   c                 ,    dt                      d| dS )z*Form the http endpoint for a specific stem^/z/$)r   )stems    r   http_endpointr   7   s     /111144488r   c                  F    t                                          dd          S )zZCheck settings and report if objects for demo purposes should be inserted during migrationinsert_demo_migrationsFr   r   r   r   r   r   ;   s     ??7???r   c                  F    t                                          dd          S )z@Return true if the http endpoint is enabled through the settingshttp_poke_enabledTr   r   r   r   http_poke_endpoint_enabledr"   @   s    ??2D999r   c                  F    t                                          dd          S )z7Return cache timeout, in seconds, for initial argumentscache_timeout_initial_arguments<   r   r   r   r   r$   r$   D   s    ??@"EEEr   c                  J    t                                          dd          } | S )zaReturn True if cache to be used for setting and getting initial arguments, or False for a sessioncache_argumentsTr   )setget_locations    r   initial_argument_locationr)   H   s$     $oo))*;TBBOr   c                 D   |dS t          |t                    rt          j        |          }dt          t	          j                                                  dd          z  }t                      r#t          j	        ||t                                 n
|| j        |<   |S )z>Store initial arguments, if any, and return a cache identifierNzdpd-initial-args-%s- )
isinstancestrjsonloadsuuiduuid4replacer)   r   setr$   session)requestinitial_argumentscache_ids      r   store_initial_argumentsr9   O   s      t #S)) : J'899 %s4:<<'8'8'@'@b'I'IIH !"" 6	(-/N/P/PQQQQ$5!Or   c                 h    |dS t                      rt          j        |          S | j        |         S )z*Extract initial arguments for the dash appN)r)   r   r   r5   )r6   r8   s     r   get_initial_argumentsr;   d   s:     t "" #y"""?8$$r   c                  F    t                                          dd          S )Nstatic_asset_rootz
dpd/assetsr   r   r   r   r=   r=   o   s    ??2<@@@r   c                 ~    t                      dd                    |                     d                    d|}|S )Nr   .)r=   joinsplit)module_name
asset_pathpath_contribs      r   full_asset_pathrE   r   sH     1 3 3 3 3 #):):3)?)? @ @ @ @ *
,L r   c                 <    t          t          | |                    S r	   )static_pathrE   )rB   rC   s     r   static_asset_pathrH   x   s    {J??@@@r   c                  F    t                                          dd          S )Nserve_locallyFr   r   r   r   rJ   rJ   {   s    ??666r   c                 <    	 t           j        }n	#  d}Y nxY w|| S )Nz/static/)r   
STATIC_URL)relative_path
static_urls     r   rG   rG   ~   s2     (

 


J..s    c                  r    t                                          dd          } | rt          |           }|S d S )z\Return a function that performs lookup for aa stateless app, given its name, or returns Nonestateless_loaderNc                     d S r	   r   )_s    r   <lambda>z+stateless_app_lookup_hook.<locals>.<lambda>   s    T r   )r   r   r   )	func_namefuncs     r   stateless_app_lookup_hookrV      sB     ##$6==I Y'' >r   r	   )__doc__r/   r1   _plotly_utils.optional_importsr   django.confr   django.core.cacher   django.utils.module_loadingr   django_plotly_dash._patchesr   r   r   r   r   r   r"   r$   r)   r9   r;   r=   rE   rH   rJ   rG   rV   r   r   r   <module>r]      s   0   6 5 5 5 5 5 !           # # # # # # 5 5 5 5 5 5 ? ? ? ? ? ?0 0 0= = =: : :9 9 9@ @ @
: : :F F F     *	% 	% 	% 	%A A A  A A A7 7 7/ / /	 	 	 	 	r   