https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/django/contrib/gis/utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/django/contrib/gis/utils/ogrinspect.pyc
�
r�\c
@s�dZddlmZddlmZddlmZmZmZm	Z	m
Z
mZddlm
Z
dded�Zd	�Zdddedeeeed
�	ZdS(s�
This module is for inspecting OGR data sources and generating either
models for GeoDjango and/or mapping dictionaries for use with the
`LayerMapping` utility.
i����(tzip(t
DataSource(tOFTDatetOFTDateTimet
OFTIntegertOFTRealt	OFTStringtOFTTime(tsixtgeomic	Cs�t|tj�r!t|�}nt|t�r3ntd��i}xH||jD]9}|j�}|ddkr�|d7}n|||<qSW||j}|r�|jd
kr�d}nd	}|t	|�j
�||<|S(s�
    Given a DataSource, generates a dictionary that may be used
    for invoking the LayerMapping utility.

    Keyword Arguments:
     `geom_name` => The name of the geometry field to use for the model.

     `layer_key` => The key for specifying which layer in the DataSource to use;
       defaults to 0 (the first layer).  May be an integer index or a string
       identifier for the layer.

     `multi_geom` => Boolean (default: False) - specify as multigeometry.
    s>Data source parameter must be a string or a DataSource object.i����t_tfieldiiitMULTIt(iii(t
isinstanceRtstring_typesRt	TypeErrortfieldstlowert	geom_typetnumtstrtupper(	tdata_sourcet	geom_namet	layer_keyt
multi_geomt_mappingRtmfieldtgtypetprefix((sE/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/ogrinspect.pytmappings"

	cOs djd�t||�D��S(s�

    Given a data source (either a string or a DataSource object) and a string
    model name this function will generate a GeoDjango model.

    Usage:

    >>> from django.contrib.gis.utils import ogrinspect
    >>> ogrinspect('/path/to/shapefile.shp','NewModel')

    ...will print model definition to stout

    or put this in a python script and use to redirect the output to a new
    model like:

    $ python generate_model.py > myapp/models.py

    # generate_model.py
    from django.contrib.gis.utils import ogrinspect
    shp_file = 'data/mapping_hacks/world_borders.shp'
    model_name = 'WorldBorders'

    print(ogrinspect(shp_file, model_name, multi_geom=True, srid=4326,
                     geom_name='shapes', blank=True))

    Required Arguments
     `datasource` => string or DataSource object to file pointer

     `model name` => string of name of new model class to create

    Optional Keyword Arguments
     `geom_name` => For specifying the model name for the Geometry Field.
       Otherwise will default to `geom`

     `layer_key` => The key for specifying which layer in the DataSource to use;
       defaults to 0 (the first layer).  May be an integer index or a string
       identifier for the layer.

     `srid` => The SRID to use for the Geometry Field.  If it can be determined,
       the SRID of the datasource is used.

     `multi_geom` => Boolean (default: False) - specify as multigeometry.

     `name_field` => String - specifies a field name to return for the
       `__unicode__`/`__str__` function (which will be generated if specified).

     `imports` => Boolean (default: True) - set to False to omit the
       `from django.contrib.gis.db import models` code from the
       autogenerated models thus avoiding duplicated imports when building
       more than one model by batching ogrinspect()

     `decimal` => Boolean or sequence (default: False).  When set to True
       all generated model fields corresponding to the `OFTReal` type will
       be `DecimalField` instead of `FloatField`.  A sequence of specific
       field names to generate as `DecimalField` may also be used.

     `blank` => Boolean or sequence (default: False).  When set to True all
       generated model fields will have `blank=True`.  If the user wants to
       give specific fields to have blank, then a list/tuple of OGR field
       names may be used.

     `null` => Boolean (default: False) - When set to True all generated
       model fields will have `null=True`.  If the user wants to specify
       give specific fields to have null, then a list/tuple of OGR field
       names may be used.

    Note: This routine calls the _ogrinspect() helper to do the heavy lifting.
    s
css|]}|VqdS(N((t.0ts((sE/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/ogrinspect.pys	<genexpr>ts(tjoint_ogrinspect(targstkwargs((sE/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/ogrinspect.pyt
ogrinspect0sDc#st|tj�r!t|�}nt|t�r3ntd��||}|j��fd�}||
��||	��||�}
��fd�}|r�dVdVdVnd|Vxrt�|j|j|j	�D]R\}}}}|j
�}|dd	kr|d
7}n||�}|tkrj|j
�|
krTd||||fVq)d||d
fVq�|tkr�d||d
fVq�|t
kr�d|||fVq�|tkr�d||d
fVq�|tkr�d||d
fVq�|tkrd||d
fVq�td||f��q�W|j}|r[|jd kr[d|j}n	|j}|dkr�|jdkr�d}q�|jj}|dkr�d}q�|dkr�d}q�d|}n
d|}d|||fVdV|rdVdtjr	dnd|fVndS(!s�
    Helper routine for `ogrinspect` that generates GeoDjango models corresponding
    to the given data source.  See the `ogrinspect` docstring for more details.
    s>Data source parameter must be a string or a DataSource object.cs]t|ttf�r2g|D]}|j�^qS|rUg�D]}|j�^q?SgSdS(N(RtlistttupleR(tkwargR!(t
ogr_fields(sE/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/ogrinspect.pyt
process_kwarg�s
csig}|j��kr(|jd�n|j��krJ|jd�n|raddj|�SdSdS(Ns	null=Trues
blank=Trues, R
(RtappendR"(t
field_nametkwlist(tblank_fieldstnull_fields(sE/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/ogrinspect.pytget_kwargs_str�ssF# This is an auto-generated Django model module created by ogrinspect.s(from django.contrib.gis.db import modelsR
sclass %s(models.Model):i����R
Rs@    %s = models.DecimalField(max_digits=%d, decimal_places=%d%s)s    %s = models.FloatField(%s)is     %s = models.IntegerField(%s)s*    %s = models.CharField(max_length=%s%s)s    %s = models.DateField(%s)s!    %s = models.DateTimeField(%s)s    %s = models.TimeField(%s)sUnknown field type %s in %siisMulti%sssrid=-1i�ssrid=%ss    %s = models.%s(%s)s!    objects = models.GeoManager()s$    def __%s__(self): return self.%sRtunicodeN(iii(RRRRRRRtfield_widthstfield_precisionstfield_typesRRRRRRRRRtdjangotNonetsrstsridtPY3(Rt
model_nameRRR9Rt
name_fieldtimportstdecimaltblanktnulltlayerR+tdecimal_fieldsR1R-twidtht	precisiont
field_typeRt
kwargs_strRt
geom_fieldtsrid_str((R/R0R*sE/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/ogrinspect.pyR#vsr
		1
					

N(t__doc__tdjango.utils.six.movesRtdjango.contrib.gis.gdalRtdjango.contrib.gis.gdal.fieldRRRRRRtdjango.utilsRtFalseRR&R7tTrueR#(((sE/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/ogrinspect.pyt<module>s.$	F		

https://t.me/AnonymousX5 - 2025