a
    1$e5                     @   s   d Z ddlmZ ddlZeddZG dd deZdd	 Zed
ddeddZdd Z	dd Z
dd Zede
 de	edZdd ZedddeddZeeeedZdS )z
Lightweight options machinery.

Based on https://github.com/topper-123/optioneer, but simplified (don't deal
with nested options, deprecated options, ..), just the attribute-style dict
like holding the options and giving a nice repr.
    )
namedtupleNOptionz(key default_value doc validator callbackc                       s@   e Zd ZdZ fddZdd Zdd Zdd	 Zd
d Z  Z	S )Optionsz5Provide attribute-style access to configuration dict.c                    s@   t  d| i }| D ]\}}|j||< qt  d| d S )N_options_config)super__setattr__itemsdefault_value)selfoptionsconfigkeyoption	__class__ M/var/www/html/django/DPS/env/lib/python3.9/site-packages/geopandas/_config.py__init__   s
    zOptions.__init__c                 C   sR   || j v rB| j| }|jr$|| || j |< |jrN||| nd}t|d S )Nz.You can only set the value of existing options)r   r   	validatorcallbackAttributeError)r   r   valuer   msgr   r   r   r      s    



zOptions.__setattr__c                 C   s,   z| j | W S  ty&   tdY n0 d S )NzNo such option)r   KeyErrorr   )r   r   r   r   r   __getattr__(   s    zOptions.__getattr__c                 C   s   t | j S )N)listr   keys)r   r   r   r   __dir__.   s    zOptions.__dir__c                 C   s   | j j}d}| j D ]d\}}dj|| j| |jd}||7 }|jr\dt	j
|jdd}nd}t	j|dd	}||d 7 }qd
}|d|}d|||S )N z&{key}: {cur!r} [default: {default!r}]
)r   curdefault
F   )widthzNo description available.z    )prefixz
  z{}({}{}))r   __name__r   r	   formatr   r
   docjointextwrapwrapindentreplace)r   clsdescriptionr   r   descrZdoc_textspacer   r   r   __repr__1   s    zOptions.__repr__)
r&   
__module____qualname____doc__r   r   r   r   r2   __classcell__r   r   r   r   r      s   	r   c                 C   s4   | d ur0t | tr(d|   kr&dks0n tdd S )Nr      z,Invalid value, needs to be an integer [0-16])
isinstanceint
ValueErrorr   r   r   r   _validate_display_precisionE   s     r<   display_precisionzThe precision (maximum number of decimals) of the coordinates in the WKT representation in the Series/DataFrame display. By default (None), it tries to infer and use 3 decimals for projected coordinates and 5 decimals for geographic coordinates.)r   r
   r(   r   r   c                 C   s    t | tstdt| d S )NzExpected bool value, got {0})r8   bool	TypeErrorr'   typer;   r   r   r   _validate_boolY   s    
rA   c                  C   s   dd l m}  | jS )Nr   )geopandas._compat_compatZ
USE_PYGEOS)compatr   r   r   _default_use_pygeos^   s    rE   c                 C   s&   | dksJ dd l m} || d S )N
use_pygeosr   )rB   rC   Zset_use_pygeos)r   r   rD   r   r   r   _callback_use_pygeosd   s    rG   rF   zWhether to use PyGEOS to speed up spatial operations. The default is True if PyGEOS is installed, and follows the USE_PYGEOS environment variable if set.c                 C   s$   | d ur | dvr t d|  dd S )N)ZpyogrioZfionaz$Expected 'pyogrio' or 'fiona', got '')r:   r;   r   r   r   _validate_io_enginex   s    rI   	io_enginezXThe default engine for ``read_file`` and ``to_file``. Options are 'pyogrio' and 'fiona'.)r=   rF   rJ   )r5   collectionsr   r*   r   objectr   r<   r=   rA   rE   rG   rF   rI   rJ   r   r   r   r   r   <module>   sH   
6