a
    1$e	                  	   @   s   d Z ddlmZ ddlZejddddZejdd	d
dZdd Zdd Zdd Z	dd Z
ejddddde	ddZejdddde	ddZdS )z$Common commandline options for `fio`    )defaultdictNz	--src-crsz	--src_crszSource CRS.)helpz	--dst-crsz	--dst_crszDestination CRS.c                 C   s    |du s|  s|S t|S dS )zLet --layer be a name or index.N)isdigitint)ctxparamvalue r	   M/var/www/html/django/DPS/env/lib/python3.9/site-packages/fiona/fio/options.pycb_layer   s    r   c                 C   sB   t t}|D ]0}|dD ] }|d\}}|| | qq|S )z
    Transform layer options from strings ("1:a,1:b", "2:a,2:c,2:z") to
    {
    '1': ['a', 'b'],
    '2': ['a', 'c', 'z']
    }
    ,:)r   listsplitappend)r   r   r   outrawvZdsnamer	   r	   r
   cb_multilayer   s    r   c                 C   sp   |si S i }|D ]V}d|vr.t d| q|dd\}}| }| }| dv r^dn|||< q|S dS )a{  
    click callback to validate `--opt KEY1=VAL1 --opt KEY2=VAL2` and collect
    in a dictionary like the one below, which is what the CLI function receives.
    If no value or `None` is received then an empty dictionary is returned.

        {
            'KEY1': 'VAL1',
            'KEY2': 'VAL2'
        }

    Note: `==VAL` breaks this as `str.split('=', 1)` is used.

    =z Invalid syntax for KEY=VAL arg:    )nonenullnilZnadaN)clickBadParameterr   lower)r   r   r   r   pairkr   r	   r	   r
   
cb_key_val%   s    r    c                 C   sX   |  D ]J}|dd tdt| d D vr|d || d  }td| dqdS )	zF
    Ensure file indexes provided in the --layer option are valid
    c                 S   s   g | ]}t |qS r	   )str).0r   r	   r	   r
   
<listcomp>I       z2validate_multilayer_file_index.<locals>.<listcomp>r   r   r   zLayer z does not existN)keysrangelenr   r   )filesZ	layerdictkeylayerr	   r	   r
   validate_multilayer_file_indexD   s     r+   z--coz	--profileZcreation_optionsz
NAME=VALUETzlDriver specific creation options. See the documentation for the selected output driver for more information.)metavarmultiplecallbackr   z--ooZopen_optionszhDriver specific open options. See the documentation for the selected output driver for more information.)__doc__collectionsr   r   optionZsrc_crs_optZdst_crs_optr   r   r    r+   Zcreation_optZopen_optr	   r	   r	   r
   <module>   s2   
