
    rbi                         d Z ddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z
 dadadeez  ddfdZdeez  ddfd	Zdefd
ZdS )z.
Module for managing the PROJ data directory.
    N)Path)_set_context_data_dirget_user_data_dir)DataDirErrorproj_data_dirreturnc                 D    t          |           adat                       dS )z
    Set the data directory for PROJ to use.

    Parameters
    ----------
    proj_data_dir: str | Path
        The path to the PROJ data directory.
    N)str_USER_PROJ_DATA_VALIDATED_PROJ_DATAr   r   s    ^/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/pyproj/datadir.pyset_data_dirr      s+     -((O     c                     t          t          j                            t	                      t          |           g                     dS )z
    Add an additional data directory for PROJ to use.

    Parameters
    ----------
    proj_data_dir: str | Path
        The path to the PROJ data directory.
    N)r   ospathsepjoinget_data_dirr
   r   s    r   append_data_dirr   )   s7     ,..#m2D2D!EFFGGGGGr   c                     t           t           S t          t                                                    j        dz  dz  dz  } t
          j                            dt
          j                            dd                    }t          t          j	        dd          }t          t          j	        ddd          }d	 fd
} |t                    rt          a n |           rt          |           a n ||          r|a n |          rt          |          a n |          rt          |          a nqt          j        dt          j	                  }|t          j        d          }|9t          |          j        j        dz  dz  } |          rt          |          a t           t          d          t           S )a  
    The order of preference for the data directory is:

    1. The one set by pyproj.datadir.set_data_dir (if exists & valid)
    2. The internal proj directory (if exists & valid)
    3. The directory in PROJ_DATA (PROJ 9.1+) | PROJ_LIB (PROJ<9.1) (if exists & valid)
    4. The directory on sys.prefix (if exists & valid)
    5. The directory on the PATH (if exists & valid)

    Returns
    -------
    str:
        The valid data directory.

    Nproj_dirshareproj	PROJ_DATAPROJ_LIB Libraryc                 R    | $t          | d                                          rdS dS )Nzproj.dbTF)r   exists)potential_data_dirs    r   valid_data_dirz$get_data_dir.<locals>.valid_data_dirN   s3    *'33::<< + 4ur   c                 p    | dS |                      t          j                  D ]} |          r dS d S )NFT)splitr   r   )potential_data_dirsr   r"   s     r   valid_data_dirsz%get_data_dir.<locals>.valid_data_dirsV   sP    &5066rzBB 	 	M~m,, tttr   )pathzValid PROJ data directory not found. Either set the path using the environmental variable PROJ_DATA (PROJ 9.1+) | PROJ_LIB (PROJ<9.1) or with `pyproj.datadir.set_data_dir`.)r   r   __file__absoluteparentr   environgetsysprefixr   r
   shutilwhichr   )internal_datadirproj_lib_dirsprefix_datadirconda_windows_prefix_datadirr&   proj_exesystem_proj_dirr"   s          @r   r   r   5   s   $ '##H~~..007*DwNQWWJNN;
z20N0NOOM#*gv66N#'
Iw#O#O        '' <.	(	)	) <"#344		'	' <,		'	' <">22	4	5	5 	<"#?@@<SZ888|F++H"8nn3:WDvMO~o.. <'*?';';$#2
 
 	
  r   )__doc__r   r/   r-   pathlibr   pyproj._contextr   r   pyproj.exceptionsr   r   r   r
   r   r   r    r   r   <module>r<      s   
 
			  



              + * * * * * d
 t    (	H3: 	H$ 	H 	H 	H 	HC c C  C  C  C  C  C r   