U
    Vb7                     @   s   d Z dZ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
mZ deeeeef eed	d
dZedddZedddZdS )zCopyright 2021, 3LizzGPL version 3zinfo@3liz.org    N)Path)Union)QgisQgsMessageLogT)valdefault_valuereturnc                 C   s&   t | tr|  dkS | sdS |S dS )z( Convert lizmap config value to boolean )yestruet1FN)
isinstancestrlower)r   r    r   //var/qgis-server/plugins/lizmap/server/tools.pyto_bool   s
    
r   )r   c                  C   sd   t tjjd} t }z|j| dd W n& tk
rR   t	ddt
j Y dS X |d d S d	S )
z% Returns the Lizmap current version. zmetadata.txtutf8)encodingzqError, an UnicodeDecodeError occurred while reading the metadata.txt. Is the locale correctly set on the server ?LizmapNULLgeneralversionN)r   __file__parentjoinpathconfigparserConfigParserreadUnicodeDecodeErrorr   
logMessager   Critical)	file_pathconfigr   r   r   r      s     r   c                   C   s.   t tjdddds*tddtj dS dS )z! Check the server configuration. Z"QGIS_SERVER_LIZMAP_REVEAL_SETTINGS F)r   u   Please read the documentation how to enable the Lizmap API on QGIS server side https://docs.lizmap.com/current/en/install/pre_requirements.html#lizmap-server-plugin An environment variable must be enabled to have Lizmap Web Client ≥ 3.5.r   T)r   osenvirongetr   r    r   r!   r   r   r   r   check_environment_variable3   s    r(   )T)__copyright____license__	__email__r   r%   pathlibr   typingr   	qgis.corer   r   r   intfloatboolr   r   r(   r   r   r   r   <module>   s    