ó
i4Vdc           @   sŽ   d  d l  Z  d  d l m Z d  d l m Z m Z d  d l m Z d e  j f d „  ƒ  YZ	 d e  j f d „  ƒ  YZ
 d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿN(   t   gdal(   t   BaseCommandt   CommandError(   t   get_func_argst   LayerOptionActionc           B   s   e  Z d  Z d d „ Z RS(   sy   
    Custom argparse action for the `ogrinspect` `layer_key` keyword option
    which may be an integer or a string.
    c         C   sH   y t  | |  j t | ƒ ƒ Wn$ t k
 rC t  | |  j | ƒ n Xd  S(   N(   t   setattrt   destt   intt
   ValueError(   t   selft   parsert	   namespacet   valuet   option_string(    (    s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pyt   __call__   s    N(   t   __name__t
   __module__t   __doc__t   NoneR   (    (    (    s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pyR      s   t   ListOptionActionc           B   s   e  Z d  Z d d „ Z RS(   s®   
    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.
    c         C   sH   | j  ƒ  d k r( t | |  j t ƒ n t | |  j | j d ƒ ƒ d  S(   Nt   truet   ,(   t   lowerR   R   t   Truet   split(   R	   R
   R   R   R   (    (    s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pyR      s    N(   R   R   R   R   R   (    (    (    s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pyR      s   t   Commandc           B   s&   e  Z d  Z e Z d „  Z d „  Z RS(   s³   Inspects 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      
   C   sx  | j  d d d ƒ| j  d d d ƒ| j  d d d d	 t d
 t d d ƒ| j  d d d d	 t d
 t d d ƒ| j  d d d d
 d d d ƒ| j  d d d d	 t d
 d d d ƒ| j  d d	 d d d d
 t d d ƒ| j  d d d d d ƒ| j  d d	 d d d  d
 t d d! ƒ| j  d" d d# d	 t d
 t d d$ ƒ| j  d% d d& d d' ƒ| j  d( d	 d d d) d d* ƒd  S(+   Nt   data_sourcet   helps   Path to the data source.t
   model_names   Name of the model to create.s   --blankR   t   blankt   actiont   defaults–   Use 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.s	   --decimalt   decimalsž   Use 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.s   --geom-namet	   geom_namet   geomsD   Specifies the model name for the Geometry Field (defaults to `geom`)s   --layert	   layer_keyi    sš   The 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.s   --multi-geomt
   store_truet
   multi_geoms?   Treat the geometry in the data source as a geometry collection.s   --name-fieldt
   name_fieldsJ   Specifies a field name to return for the `__unicode__`/`__str__` function.s   --no-importst   store_falset   importssD   Do not include `from django.contrib.gis.db import models` statement.s   --nullt   nulls•   Use 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.s   --sridt   sridse   The SRID to use for the Geometry Field. If it can be determined, the SRID of the data source is used.s	   --mappingt   mappings8   Generate mapping dictionary for use with `LayerMapping`.(   t   add_argumentR   t   FalseR   R   (   R	   R
   (    (    s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pyt   add_arguments(   s4    c            s¥  | j  d ƒ | j  d ƒ } } t j s7 t d ƒ ‚ n  y t j | ƒ } Wn" t j k
 rn } t | ƒ ‚ n Xd d l m ‰  m } ‡  f d †  | j	 ƒ  Dƒ } g  ˆ  | | |  D] }	 |	 ^ q´ }
 | d r”i | d d 6| d	 d	 6| d
 d
 6} | | |  } d „  | j	 ƒ  Dƒ ‰ |
 j
 d d | d | j ƒ  g ƒ |
 j
 ‡ f d †  | | d	 j Dƒ ƒ |
 j
 d | d | | d f d g ƒ n  d j |
 ƒ d S(   NR   R   s4   GDAL is required to inspect geospatial data sources.iÿÿÿÿ(   t   _ogrinspectR+   c            s=   i  |  ]3 \ } } | t  ˆ  ƒ k r | d  k	 r | | “ q S(   N(   R   R   (   t   .0t   kt   v(   R/   (    s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pys
   <dictcomp>]   s   	 	R+   R!   R#   R%   c         S   s   i  |  ] \ } } | | “ q S(    (    (   R0   R1   R2   (    (    s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pys
   <dictcomp>k   s   	 t    s7   # Auto-generated `LayerMapping` dictionary for %s models   %s_mapping = {c         3   s#   |  ] } d  ˆ  | | f Vq d S(   s       '%s' : '%s',N(    (   R0   t   ogr_fld(   t   rev_mapping(    s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pys	   <genexpr>n   s   s       '%s' : '%s',t   }s   
(   t   popR    t   HAS_GDALR   t
   DataSourcet   GDALExceptiont#   django.contrib.gis.utils.ogrinspectR/   R+   t   itemst   extendR   t   fieldst   join(   R	   t   argst   optionsR   R   t   dst   msgR+   t   ogr_optionst   st   outputt   kwargst   mapping_dict(    (   R/   R5   s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pyt   handleN   s,    	%
,(   R   R   R   R-   t   requires_system_checksR.   RI   (    (    (    s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pyR   !   s   	&(   t   argparset   django.contrib.gisR    t   django.core.management.baseR   R   t   django.utils.inspectR   t   ActionR   R   R   (    (    (    s   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/management/commands/ogrinspect.pyt   <module>   s   