
    Dvg                         d dl Z d dlmZ d dlmZmZ d dlmZ  G d de j                  Z	 G d de j                  Z
 G d	 d
e          ZdS )    N)gdal)BaseCommandCommandErrorget_func_argsc                       e Zd ZdZddZdS )LayerOptionActionzy
    Custom argparse action for the `ogrinspect` `layer_key` keyword option
    which may be an integer or a string.
    Nc                     	 t          || j        t          |                     d S # t          $ r t          || j        |           Y d S w xY wN)setattrdestint
ValueErrorselfparser	namespacevalueoption_strings        n/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/gis/management/commands/ogrinspect.py__call__zLayerOptionAction.__call__   s_    	1Ity#e**55555 	1 	1 	1Ity%000000	1s   #'  A
Ar   __name__
__module____qualname____doc__r        r   r	   r	      s2         
1 1 1 1 1 1r   r	   c                       e Zd ZdZddZdS )ListOptionActionz
    Custom argparse action for `ogrinspect` keywords that require
    a string list. If the string is 'True'/'true' then the option
    value will be a boolean instead.
    Nc                     |                                 dk    rt          || j        d           d S t          || j        |                    d                     d S )NtrueT,)lowerr   r   splitr   s        r   r   zListOptionAction.__call__   sU    ;;==F""Ity$/////Ity%++c*:*:;;;;;r   r   r   r   r   r   r    r       s2         < < < < < <r   r    c                   "    e Zd ZdZg Zd Zd ZdS )CommandzInspects the given OGR-compatible data source (e.g., a shapefile) and outputs
a GeoDjango model with the given model name. For example:
 ./manage.py ogrinspect zipcode.shp Zipcodec                 r   |                     dd           |                     dd           |                     dt          dd	           |                     d
t          dd	           |                     ddd           |                     ddt          dd           |                     ddd           |                     dd           |                     dddd           |                     d t          dd!	           |                     d"d#           |                     d$dd%           d S )&Ndata_sourcezPath to the data source.)help
model_namezName of the model to create.z--blankFzUse a comma separated list of OGR field names to add the `blank=True` option to the field definition. Set to `true` to apply to all applicable fields.)actiondefaultr*   z	--decimalzUse a comma separated list of OGR float fields to generate `DecimalField` instead of the default `FloatField`. Set to `true` to apply to all OGR float fields.z--geom-namegeomzDSpecifies the model name for the Geometry Field (defaults to `geom`))r-   r*   z--layer	layer_keyr   zThe key for specifying which layer in the OGR data source to use. Defaults to 0 (the first layer). May be an integer or a string identifier for the layer.)r   r,   r-   r*   z--multi-geom
store_truez?Treat the geometry in the data source as a geometry collection.)r,   r*   z--name-fieldz:Specifies a field name to return for the __str__() method.z--no-importsstore_falseimportszDDo not include `from django.contrib.gis.db import models` statement.)r,   r   r*   z--nullzUse a comma separated list of OGR field names to add the `null=True` option to the field definition. Set to `true` to apply to all applicable fields.z--sridzeThe SRID to use for the Geometry Field. If it can be determined, the SRID of the data source is used.z	--mappingz8Generate mapping dictionary for use with `LayerMapping`.)add_argumentr    r	   )r   r   s     r   add_argumentszCommand.add_arguments,   s   M0JKKKL/MNNN#1	 	 	
 	
 	
 	#L	 	 	
 	
 	
 	W 	 	
 	
 	

 	$? 	 	
 	
 	
 	R 	 	
 	
 	

 	M 	 	
 	
 	
 	 W	 	 	
 	
 	
 	#1	 	 	
 	
 	
 	? 	 	
 	
 	

 	K 	 	
 	
 	
 	
 	
r   c                 (   |                     d          |                     d          }}	 t          j        |          }n&# t          j        $ r}t	          |          d }~ww xY wddlmm} fd|                                D             }d  ||fi |D             }	|d         r|d         |d	         |d
         d}
 ||fi |
}d |                                D             |		                    ddd|z  d|
                                z  g           |		                    fd||d	                  j        D                        |		                    d|d         d||d                  ddg           d                    |	          S )Nr)   r+   r   )_ogrinspectmappingc                 B    i | ]\  }}|t                    v |||S r   r   ).0kvr6   s      r   
<dictcomp>z"Command.handle.<locals>.<dictcomp>}   s>     
 
 
1M+....1= q3@==r   c                     g | ]}|S r   r   )r9   ss     r   
<listcomp>z"Command.handle.<locals>.<listcomp>   s    HHH!HHHr   r7   	geom_namer/   
multi_geom)r@   r/   rA   c                     i | ]\  }}||	S r   r   )r9   r:   r;   s      r   r<   z"Command.handle.<locals>.<dictcomp>   s    AAADAq1aAAAr    z7# Auto-generated `LayerMapping` dictionary for %s modelz%s_mapping = {c              3   6   K   | ]}d |         d|dV  dS )    '': '',Nr   )r9   ogr_fldrev_mappings     r   	<genexpr>z!Command.handle.<locals>.<genexpr>   sM        G &1%9%9%9777C     r   rE   rF   rG   }
)popr   
DataSourceGDALExceptionr   #django.contrib.gis.utils.ogrinspectr6   r7   itemsextendr$   fieldsjoin)r   argsoptionsr)   r+   dsmsgr7   ogr_optionsoutputkwargsmapping_dictr6   rI   s               @@r   handlezCommand.handleo   s7   ")++m"<"<gkk,>W>WZ	$--BB! 	$ 	$ 	$s###	$
 	MLLLLLLL
 
 
 

 
 

 IH[[ZGG;GGHHH9 	 %[1$[1%l3 F
 #720000L BAL,>,>,@,@AAAKMMM !$z'7'7'9'99   MM    !'+"67>      MMM {+++\'+:N-O-O-OQ   yy   s   A A&A!!A&N)r   r   r   r*   requires_system_checksr4   r]   r   r   r   r'   r'   #   sH        	6 	  A
 A
 A
F5! 5! 5! 5! 5!r   r'   )argparsedjango.contrib.gisr   django.core.management.baser   r   django.utils.inspectr   Actionr	   r    r'   r   r   r   <module>rd      s     # # # # # # A A A A A A A A . . . . . .
1 
1 
1 
1 
1 
1 
1 
1< < < < <x < < <A! A! A! A! A!k A! A! A! A! A!r   