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 :  /usr/lib64/python2.7/site-packages/django/contrib/gis/utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib64/python2.7/site-packages/django/contrib/gis/utils/layermapping.pyc
�
r�\c@srdZddlZddlmZddlmZddlmZmZddl	m
Z
ddlmZm
Z
mZmZmZmZddlmZmZmZmZmZmZdd	lmZmZdd
lmZddlmZdefd
��YZ de fd��YZ!de fd��YZ"de fd��YZ#de fd��YZ$de%fd��YZ&dS(s�
 The LayerMapping class provides a way to map the contents of OGR
 vector files (e.g. SHP files) to Geographic-enabled Django models.

 For more information, please consult the GeoDjango documentation:
   http://geodjango.org/docs/layermapping.html
i����N(tDecimal(tObjectDoesNotExist(tconnectionstrouter(t
GeometryField(tCoordTransformt
DataSourcetOGRExceptiontOGRGeometrytOGRGeomTypetSpatialReference(tOFTDatetOFTDateTimet
OFTIntegertOFTRealt	OFTStringtOFTTime(tmodelsttransaction(tsix(t
force_textt
LayerMapErrorcBseZRS((t__name__t
__module__(((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyRst
InvalidStringcBseZRS((RR(((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyRstInvalidDecimalcBseZRS((RR(((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyRstInvalidIntegercBseZRS((RR(((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyRstMissingForeignKeycBseZRS((RR(((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyRstLayerMappingcBs�eZdZied�d6ed�d6ed�d6ed�ed�j6ed	�ed
�j6ed�ed�j6Zieej6ee	e
fej6ee	fej6e
ej6eej6e
ej6eej6ee	fej6e
ej6e
ej6e
ej6e
ej6ee	e
fej6ee	e
fej6ee	e
fej6Zd
dddeddd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+e,e,e,e,e,e-j.e,d�Z/RS(s1A class that maps OGR Layers to GeoDjango Models.t
MultiPointitMultiLineStringitMultiPolygonit
MultiPoint25DtPoint25DtMultiLineString25Dt
LineString25DtMultiPolygon25Dt
Polygon25Disutf-8tcommit_on_successcCs�t|tj�r*t|d|�|_n	||_|j||_|
dk	rU|
ntj|�|_	t
|j	j|_||_
||_|j�|jjr�t}n|j�|_|r�|j|�|_|j�|_n	||_|rddlm}||�||_n	d|_|	rG|j|	�d}|	|_n	d|_||_|dkrqd|_n+|dkr�tj |_nt!d|��dS(s
        A LayerMapping object is initialized using the given Model (not an instance),
        a DataSource (or string path to an OGR-supported data file), and a mapping
        dictionary.  See the module level docstring for more details and keyword
        argument usage.
        tencodingi����(tlookupt
autocommitR&s!Unrecognized transaction mode: %sN("t
isinstanceRtstring_typesRtdstlayertNoneRtdb_for_writetusingRtopstspatial_backendtmappingtmodeltcheck_layertmysqltFalsetgeometry_fieldt	geo_fieldt	check_srst
source_srstcoord_transformt	transformtcodecsR(R'tcheck_uniquetuniquettransaction_modettransaction_decoratorRtatomicR(tselfR4tdataR3R-R;R'RAR=R@R0R(((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyt__init__>s@	$		
		
	
		cCsI|rAt|ttf�r%t|�St|t�r8|St�ndSdS(s$This checks the `fid_range` keyword.N(R*ttupletlisttslicet	TypeErrorR.(RDt	fid_range((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pytcheck_fid_range�s
	cs�t|_i|_|jj�|jj}�fd�}x�|jj�D]�\}}y|jjj	|�}Wn't
jjk
r�td|��nX|j
j}t|t�r�|jr�td��n|j}y/|dkr�t|d�}nt|�}Wn!tk
r&td|��nX|jj}	|	jj|j�pW|j|	|�s�td||dkrudnd	|	f��n||_||_|}
n3t|t
j�r]t|t�rN|jj}xr|j�D]d\}}
||
�}y|jj	|�}Wq�t
jjk
r@td
||j
jf��q�Xq�W|}
q�td��ny|j
|jkr�td|��n||�}||}
t|
|j|j
�s�td
|
|
j|f��n|}
|
|j|<qIWdS(s�
        This checks the Layer metadata, and ensures that it is compatible
        with the mapping information and model.  Unlike previous revisions,
        there is no need to increment through each feature in the Layer.
        cs;y�j|�}Wn!tk
r6td|��nX|S(Ns4Given mapping OGR field "%s" not found in OGR Layer.(tindext
ValueErrorR(togr_map_fldtidx(t
ogr_fields(sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyt
check_ogr_fld�s

s3Given mapping field "%s" not in given Model fields.sDLayerMapping does not support more than one GeometryField per model.it25Ds'Invalid mapping for GeometryField "%s".sDInvalid mapping geometry; model has %s%s, layer geometry type is %s.s(dim=3)ts/ForeignKey mapping field "%s" not in %s fields.s.ForeignKey mapping must be of dictionary type.s0Django field type "%s" has no OGR mapping (yet).s:OGR field "%s" (of type %s) cannot be mapped to Django %s.N( R7t
geom_fieldtfieldsR-tfield_typesR3titemsR4t_metat	get_fieldRtFieldDoesNotExistRt	__class__RR*RtdimR	Rt	geom_typetnamet
startswitht
make_multit	coord_dimt
ForeignKeytdicttrelttoRJtFIELD_TYPESt
issubclass(RDtogr_field_typesRRt
field_nametogr_nametmodel_fieldtfld_nameRbtgtypetltypet
fields_valt	rel_modeltrel_namet	ogr_fieldRPt	rel_field((RQsG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyR5�sb						
'(				
cCs�t|t�r|}nWt||jj��r<|j}n3t|ttjf�rct|�}n|jj}|s�t	d��n|SdS(s?Checks the compatibility of the given spatial reference object.s#No source reference system defined.N(
R*R
R2tspatial_ref_systsrstintRR+R-R(RDR;tsr((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyR:�s	cCs~t|ttf�rAxb|D]}||jkrt�qqWn9t|tj�rn||jkrzt�qzntd��dS(sEChecks the `unique` keyword parameter -- may be a sequence or string.sBUnique keyword argument must be set with a tuple, list, or string.N(R*RHRGR3RNRR+RJ(RDR@tattr((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyR?s
cCs�i}x�|jj�D]�\}}|j|}t|t�rzy|j|j|�}Wq�tk
rvtd��q�XnCt|t	j
j�r�|j|||�}n|j
|||�}|||<qW|S(s�
        Given an OGR Feature, this will return a dictionary of keyword arguments
        for constructing the mapped model.
        s)Could not retrieve geometry from feature.(R3RXRVR*Rtverify_geomtgeomRRRtbaset	ModelBaset	verify_fktverify_ogr_field(RDtfeattkwargsRjRkRltval((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pytfeature_kwargss

csKt|jtj�r*i�|j|j6St�fd�|jD��SdS(s�
        Given the feature keyword arguments (from `feature_kwargs`) this routine
        will construct and return the uniqueness keyword arguments -- a subset
        of the feature kwargs.
        c3s|]}|�|fVqdS(N((t.0tfld(R�(sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pys	<genexpr><sN(R*R@RR+Rd(RDR�((R�sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyt
unique_kwargs3sc
Cs�t|t�r�t|tjtjf�r�|jrKt|j|j�}q�|j}|jr�t	|�|jkr�t
d|j|jt	|�f��q�nPt|t�r�t|tj
�r�ytt|j��}Wntd|j��nX|j�}|d}|d}|j|j}|dkrCt	|| �}	nt	|�|}	|	|kr�td|j|j|f��n|}nct|ttf�r�t|tj�r�yt|j�}Wq�td|j��q�Xn	|j}|S(s�
        Verifies if the OGR Field contents are acceptable to the Django
        model field.  If they are, the verified value is returned,
        otherwise the proper exception is raised.
        s@%s model field maximum string length is %s, given %s characters.s$Could not construct decimal from: %siiiseA DecimalField with max_digits %d, decimal_places %d must round to an absolute value less than 10^%d.s$Could not construct integer from: %s(R*RRt	CharFieldt	TextFieldR'Rtvaluet
max_lengthtlenRR_RtDecimalFieldRtstrRtas_tuplet
max_digitstdecimal_placestIntegerFieldRwR(
RDRsRlR�tdtdtuptdigitstd_idxtmax_prectn_prec((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyR?s>		%!

	'	cCs�i}x@|j�D]2\}}|j|||jj|��||<qWy |jj|j�j|�SWn*tk
r�td|j	|f��nXdS(s�
        Given an OGR Feature, the related model and its dictionary mapping,
        this routine will retrieve the related model for the ForeignKey
        mapping.
        s7No ForeignKey %s model found with keyword arguments: %sN(
RXRRYRZtobjectsR0tgetRRR(RDR�Rqtrel_mappingt	fk_kwargsRjRk((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyR~vs* 
cCs�|j|jkr!|j|_n|j|j|�re|j|jj}t|�}|j|�n|}|jr�|j|j�n|jS(s�
        Verifies the geometry -- will construct and return a GeometryCollection
        if necessary (for example if the model field is MultiPolygonField while
        the mapped shapefile only contains Polygons).
        (	RbRaR^tMULTI_TYPEStnumRtaddR=twkt(RDR{Rlt
multi_typetg((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyRz�s	cCs�|jj�}y>|jj|j�jd|jj�j}t|j	|�SWn@t
k
r�}d|}tjt
t
|�tj�d�nXdS(s-Returns the coordinate transformation object.tsridsBCould not translate between the data source and model geometry: %siN(R2RuR�R0R�R9R�RvRR;t	ExceptionRtreraiseRtsystexc_info(RDt
SpatialRefSyst
target_srstmsgtnew_msg((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyR<�s*
cCs.|jj}|j|j�\}}}}|S(sIReturns the GeometryField instance associated with the geographic column.(R4RYtget_field_by_nameRU(RDtoptsR�R4tdirecttm2m((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyR8�scCs)|j|jko(|jjd|jkS(s�
        Given the OGRGeomType for a geometry and its associated GeometryField,
        determine whether the geometry should be turned into a GeometryCollection.
        sMulti%s(R�R�R\Rtdjango(RDR^Rl((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyRa�scs��j|�}�rC�tks1t�t�r:d�qC��n|dd�������fd�}	�jd	k	r��j|	�}	n�jj}
|r�t|t�r�||
kr�|r�td��nd
\}}}
t	||
|�}t
|�}x�t|�D]�\}}|d|kr8t|d	�}nt||�}y"|	|||
�\}}
|}Wq
�j
ddd|f��q
Xq
Wn|	�d	S(s�
        Saves the contents from the OGR DataSource Layer into the database
        according to the mapping dictionary given at initialization.

        Keyword Parameters:
         verbose:
           If set, information will be printed subsequent to each model save
           executed on the database.

         fid_range:
           May be set with a slice or tuple of (begin, end) feature ID's to map
           from the data source.  In other words, this keyword enables the user
           to selectively import a subset range of features in the geographic
           data source.

         step:
           If set with an integer, transactions will occur at every step
           interval. For example, if step=1000, a commit would occur after
           the 1,000th feature, the 2,000th feature etc.

         progress:
           When this keyword is set, status information will be printed giving
           the number of features processed and sucessfully saved.  By default,
           progress information will pe printed every 1000 features processed,
           however, this default may be overridden by setting this keyword with an
           integer for the desired interval.

         stream:
           Status information will be written to this file handle.  Defaults to
           using `sys.stdout`, but any object with a `write` method is supported.

         silent:
           By default, non-fatal error notifications are printed to stdout, but
           this keyword may be set to disable these notifications.

         strict:
           Execution of the model mapping will cease upon the first error
           encountered.  The default behavior is to attempt to continue.
        i�ic
sv|r�j|}n	�j}xJ|D]B}|d7}y�j|�}WnBtk
r�}�rg�q8�s8�jd|j|f�q8n�Xt}�jrYy��j|�}�jj	j
�j
�j|�}	t}t
|	�j�j}
t|�j�}x|D]}|
j|�qWt|	�j|
j�Wqhtk
rU�j|�}	qhXn�j|�}	yM|	jd�j
�|d7}�r��jd|r�dnd|	f�nWn�tk
r��nmtk
r7}�r�s�jd|j��jd|�n�q8�s8�jd	||f�q8nX�r&|�d
kr&�jd||f�q&q&W||fS(Nis#Ignoring Feature ID %s because: %s
R0s%s: %s
tUpdatedtSavedsOFailed to save the feature (id: %s) into the model with the keyword arguments:
s%s
s"Failed to save %s:
 %s
Continuing
is$Processed %d features, saved %d ...
(R-R�RtwritetfidR7R@R�R4R�R0R�tTruetgetattrRUtogrRR�tsetattrR�Rtsavet
SystemExitR�(
t
feat_rangetnum_featt	num_savedt
layer_iterR�R�R�t	is_updatetu_kwargstmR{tnewR�(tprogresstprogress_intervalRDtsilenttstreamtstricttverbose(sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyt_save�sX	

!	!


*
sOThe `step` keyword may not be used in conjunction with the `fid_range` keyword.is%s
Failed to save slice: %s
s=-iN(iii(RLR�R*RwRBR.R-R�RtrangeR�t	enumerateRIR�(RDR�RKtstepR�R�R�R�t
default_rangeR�tnfeattbegR�R�tindicestn_ititendt
step_slice((R�R�RDR�R�R�R�sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyR��s4*		*D!
N(0RRt__doc__R	R�R�R
Rt	AutoFieldRRR�t
FloatFieldRt	DateFieldRt
DateTimeFieldt
EmailFieldRt	TimeFieldR�R�t	SlugFieldR�tURLFieldtBigIntegerFieldtSmallIntegerFieldtPositiveSmallIntegerFieldRgR.R�RFRLR5R:R?R�R�RR~RzR<R8RaR7R�tstdoutR�(((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyRsR










E		a		
	!		7			
			('R�R�tdecimalRtdjango.core.exceptionsRt	django.dbRRtdjango.contrib.gis.db.modelsRtdjango.contrib.gis.gdalRRRRR	R
tdjango.contrib.gis.gdal.fieldRRR
RRRRRtdjango.utilsRtdjango.utils.encodingRR�RRRRRtobjectR(((sG/tmp/pip-install-XxeQeY/django/django/contrib/gis/utils/layermapping.pyt<module>s ..

https://t.me/AnonymousX5 - 2025