403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/django/contrib/gis/utils/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/django/contrib/gis/utils/__pycache__/layermapping.cpython-311.pyc
�

�|�el��X�dZddlZddlmZmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZddlmZmZmZmZmZmZmZddlmZmZdd	lmZmZmZm Z dd
l!m"Z"Gd�de#��Z$Gd
�de$��Z%Gd�de$��Z&Gd�de$��Z'Gd�de$��Z(Gd�d��Z)dS)a
 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:
   https://docs.djangoproject.com/en/dev/ref/contrib/gis/layermapping/
�N)�Decimal�InvalidOperation)�Path)�
GeometryField)�CoordTransform�
DataSource�
GDALException�OGRGeometry�OGRGeomType�SpatialReference)�OFTDate�OFTDateTime�
OFTInteger�OFTInteger64�OFTReal�	OFTString�OFTTime)�FieldDoesNotExist�ObjectDoesNotExist)�connections�models�router�transaction)�	force_strc��eZdZdS)�
LayerMapErrorN��__name__�
__module__�__qualname__���G/usr/lib/python3/dist-packages/django/contrib/gis/utils/layermapping.pyrr��������Dr"rc��eZdZdS)�
InvalidStringNrr!r"r#r&r& r$r"r&c��eZdZdS)�InvalidDecimalNrr!r"r#r(r($r$r"r(c��eZdZdS)�InvalidIntegerNrr!r"r#r*r*(r$r"r*c��eZdZdS)�MissingForeignKeyNrr!r"r#r,r,,r$r"r,c���eZdZdZded��ded��ded��ed��jed	��ed
��jed��ed��jed
��iZieje	�ej
e�eje	�ej
e	eef�eje	eef�eje	ef�eje�eje�eje�eje�eje	ef�eje�eje�eje�eje�eje�eje	eef�ej e	eefej!e	eefej"e	eefej#e	eefi�Z$				d"d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d d d d d e2j3d fd!�Z4dS)#�LayerMappingz1A class that maps OGR Layers to GeoDjango Models.��
MultiPoint��MultiLineString��MultiPolygon�Point25D�
MultiPoint25D�
LineString25D�MultiLineString25D�
Polygon25D�MultiPolygon25DrN�utf-8�commit_on_successTc�P�t|ttf��rt||���|_n||_|j||_|
�|
nt
j|��|_t|jj
|_||_||_
|���t|jjjr|���|_nd}|r4|�|��|_|���|_n||_|rddlm}||��||_nd|_|	r|�|	��d}|	|_nd|_||_|dkr	d|_dS|dkrt<j|_dStAd|z���)	a
        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.
        )�encodingNFr)�lookup�
autocommitr<z!Unrecognized transaction mode: %s)!�
isinstance�strrr�ds�layerr�db_for_write�usingr�ops�spatial_backend�mapping�model�check_layer�features�supports_transform�geometry_field�	geo_field�	check_srs�
source_srs�coord_transform�	transform�codecsr?r>�check_unique�unique�transaction_mode�transaction_decoratorr�atomicr)�selfrJ�datarIrDrQr>rWrSrVrFr?s            r#�__init__zLayerMapping.__init__Vs����d�S�$�K�(�(�	� ���9�9�9�D�G�G��D�G��W�U�^��
�#�/�U�U�V�5H��5O�5O��
�*�4�:�6�:��������
�	
�������t�z�"�+�>�	�!�0�0�2�2�D�N�N��I�
�	'�"�n�n�Z�8�8�D�O�!�1�1�3�3�D�N�N�&�D�N��	!�
&�%�%�%�%�%��F�8����$�D�M�M� �D�M��	����f�%�%�%�+�� �D�K�K��D�K�!1����|�+�+�)-�D�&�&�&�
�!4�
4�
4�)4�);�D�&�&�&�� C�FV� V�W�W�Wr"c��|rCt|ttf��r	t|�St|t��r|St�dS)zCheck the `fid_range` keyword.N)rA�tuple�list�slice�	TypeError)rZ�	fid_ranges  r#�check_fid_rangezLayerMapping.check_fid_range�sM���	��)�e�T�]�3�3�
 ��i�(�(��I�u�-�-�
 � � ����4r"c
���d|_i|_|jj�|jj}�fd�}|j���D�]z\}}	|jj�|��}n #t$rtd|z���wxYw|jj}t|t��r�|jrtd���|j}	|dkrt!|dz��}nt!|��}n #t"$rtd|z���wxYw|jj}	|	j�|j��s6|�|	|��s td|�|dkrd	nd
�d|	�d����||_||_|}
�n.t|t.j��r�t|t2��r}|jj}|���D]Y\}}
||
��}	|j�|���,#t$r!td
|�d|jj�d����wxYw|}
n�t7d���|j|jvrtd|z���||��}||}
t;|
|j|j��std|
�d|
j�d|�d����|}
|
|j|<��|dS)z�
        Check the Layer metadata and ensure that it's compatible with the
        mapping information and model. Unlike previous revisions, there is no
        need to increment through each feature in the Layer.
        Fc�v��	��|��}n #t$rtd|z���wxYw|S)Nz4Given mapping OGR field "%s" not found in OGR Layer.)�index�
ValueErrorr)�ogr_map_fld�idx�
ogr_fieldss  �r#�
check_ogr_fldz/LayerMapping.check_layer.<locals>.check_ogr_fld�sW���
j� �&�&�{�3�3�����
j�
j�
j�#�$Z�]h�$h�i�i�i�
j�����Js��6z3Given mapping field "%s" not in given Model fields.zDLayerMapping does not support more than one GeometryField per model.r3�25Dz'Invalid mapping for GeometryField "%s".z$Invalid mapping geometry; model has z(dim=3)�z, layer geometry type is �.zForeignKey mapping field "z	" not in z fields.z.ForeignKey mapping must be of dictionary type.z0Django field type "%s" has no OGR mapping (yet).zOGR field "z" (of type z) cannot be mapped to Django N)�
geom_field�fieldsrD�field_typesrI�itemsrJ�_meta�	get_fieldrr�	__class__rrAr�dimrr	�	geom_type�name�
startswith�
make_multi�	coord_dimr�
ForeignKey�dict�remote_fieldra�FIELD_TYPES�
issubclass)rZ�ogr_field_typesrk�
field_name�ogr_name�model_field�fld_namer{�gtype�ltype�
fields_val�	rel_model�rel_name�	ogr_fieldrirjs               @r#rKzLayerMapping.check_layer�s���� �������Z�&�
��*�0��	�	�	�	�	�%)�L�$6�$6�$8�$8�D	1�D	1� �J��
h�"�j�.�8�8��D�D����$�
h�
h�
h�#�$Y�\f�$f�g�g�g�
h����#�,�5�H��+�}�5�5�7
)��?�p�'�(n�o�o�o�(�O�	�`� �A�~�~� +�H�u�,<� =� =��� +�H� 5� 5����$�`�`�`�'�(Q�T^�(^�_�_�_�`�����
�,���
�-�-�e�j�9�9�`�T�_�_�U�T_�=`�=`�`�'�-�)1��	�Q���9�9�TV�3V�3V�X]�X]�X]�)_�`�`�`�#-���!*���(�
�
��K��):�;�;�
)��h��-�-�V� +� 8� >�I�/7�~�~�/?�/?�Z�Z�+��)�+�m�I�6�6��Z�%�O�5�5�h�?�?�?�?��0�Z�Z�Z�"/�-�19���9�;N�;W�;W�;W�1Y�#Z�#Z�Z�Z����"+�J�J�#�$T�U�U�U��(��0@�@�@�'�(Z�]e�(e�f�f�f�$�m�H�-�-��+�C�0�	�"�)�T�-=�k�>S�-T�U�U�S�'�-�)2���I�4F�4F�4F����)R�S�S�S�(�
�&0�D�K�
�#�#�ID	1�D	1s$�
A-�-B
�(C5�5D�(H�+H.c�&�t|t��r|}ngt||j�����r|j}n8t|t
tf��rt|��}n|jj}|std���|S)z>Check the compatibility of the given spatial reference object.z#No source reference system defined.)	rArrH�spatial_ref_sys�srs�intrBrDr)rZrQ�srs   r#rPzLayerMapping.check_srss����j�"2�3�3�	 ��B�B�
�
�D�$8�$H�$H�$J�$J�
K�
K�	 ���B�B�
�
�S�#�J�
/�
/�	 �!�*�-�-�B�B����B��	�� E�F�F�F��Ir"c���t|ttf��r|D]}||jvrt��dSt|t
��r||jvrt�dSt
d���)zDCheck the `unique` keyword parameter -- may be a sequence or string.zBUnique keyword argument must be set with a tuple, list, or string.N)rAr_r^rIrgrBra)rZrV�attrs   r#rUzLayerMapping.check_uniques����f�t�U�m�,�,�
	b��
%�
%���t�|�+�+�$�$�,�
%�
%����
$�
$�	b��T�\�)�)� � �*�)��`�a�a�ar"c��i}|j���D]�\}}|j|}t|t��r:	|�|j|��}np#t$rtd���wxYwt|tj
j��r|�|||��}n|�
|||��}|||<��|S)z{
        Given an OGR Feature, return a dictionary of keyword arguments for
        constructing the mapped model.
        z)Could not retrieve geometry from feature.)rIrrrprAr�verify_geom�geomr	rr�base�	ModelBase�	verify_fk�verify_ogr_field)rZ�feat�kwargsr�r�r��vals       r#�feature_kwargszLayerMapping.feature_kwargs,s�����%)�L�$6�$6�$8�$8�	%�	%� �J���+�j�1�K��+�}�5�5�
I�U��*�*�4�9�k�B�B�C�C��$�U�U�U�'�(S�T�T�T�U�����K���)>�?�?�
I��n�n�T�;��A�A����+�+�D��N�K�H�H��"%�F�:����
s�A � A:c���t|jt��r|j�|jiS�fd�|jD��S)z�
        Given the feature keyword arguments (from `feature_kwargs`), construct
        and return the uniqueness keyword arguments -- a subset of the feature
        kwargs.
        c�"��i|]}|�|��Sr!r!)�.0�fldr�s  �r#�
<dictcomp>z.LayerMapping.unique_kwargs.<locals>.<dictcomp>Vs���<�<�<��C����<�<�<r")rArVrB)rZr�s `r#�
unique_kwargszLayerMapping.unique_kwargsMsI����d�k�3�'�'�	=��K����!4�5�5�<�<�<�<���<�<�<�<r"c	�t�t|t��r�t|tjtjf��r�|jr"|j�t|j|j��}n|j}|jrI|�Gt|��|jkr/t|j�d|j�dt|���d�����nzt|t��r�t|tj
��r�	tt|j����}n%#t $rt#d|jz���wxYw|���}|d}|d}|j|jz
}|dkrt|d|���}	nt|��|z}	|	|krt#d	|j|j|fz���|}nxt|ttf��rUt|tj��r;	t-|j��}n,#t.$rt1d
|jz���wxYw|j}|S)z�
        Verify if the OGR Field contents are acceptable to the model field. If
        they are, return the verified value, otherwise raise an exception.
        Nz& model field maximum string length is z, given z characters.z$Could not construct decimal from: %sr/r1rzeA DecimalField with max_digits %d, decimal_places %d must round to an absolute value less than 10^%d.z$Could not construct integer from: %s)rArr�	CharField�	TextFieldr>�valuer�
max_length�lenr&rxr�DecimalFieldrrB�DecimalInvalidOperationr(�as_tuple�
max_digits�decimal_places�IntegerFieldr�rgr*)
rZr�r�r��d�dtup�digits�d_idx�max_prec�n_precs
          r#r�zLayerMapping.verify_ogr_fieldYsn��

�y�)�,�,�1	"��;��)9�6�;K�(L�M�M�1	"��}�
&���!<� �	����?�?����o���%�
Z�#�/�c�#�h�h��I_�>_�>_�#�%0�%5�%5�%5�{�7M�7M�7M�s�SV�x�x�x�x�%Y�Z�Z�Z��
�	�7�
+�
+�&	"�
�;��H[�0\�0\�&	"�
_��C�	��0�0�1�1����*�
_�
_�
_�$�%K�i�o�%]�^�^�^�
_�����:�:�<�<�D��!�W�F���G�E�#�-��0J�J�H��q�y�y��V�F�U�F�^�,�,����V���u�,���� � �$�B� �+�[�-G��R�S����
�C�C�
�	�G�Y�#7�
8�
8�	"�Z��U[�Uh�=i�=i�	"�
_��)�/�*�*�����
_�
_�
_�$�%K�i�o�%]�^�^�^�
_�����/�C��
s�.!D�"D2�7H�"H.c�N�i}|���D]<\}}|�|||j�|����||<�=	|j�|j��jdi|��S#t$rtd|j	�d|�����wxYw)z�
        Given an OGR Feature, the related model and its dictionary mapping,
        retrieve the related model for the ForeignKey mapping.
        zNo ForeignKey z% model found with keyword arguments: Nr!)
rrr�rsrt�objectsrF�getrr,r)rZr�r��rel_mapping�	fk_kwargsr�r�s       r#r�zLayerMapping.verify_fk�s����	�$/�$5�$5�$7�$7�	q�	q� �J��$(�$9�$9�$�x�.�)�/�Jc�Jc�dn�Jo�Jo�$p�$p�I�j�!�!�	�:�9�$�*�*�4�:�6�6�:�G�G�Y�G�G�G��!�	�	�	�#�#��#�#�#�Y�Y�0���
�	���s�)A?�?%B$c�<�|j|jkr|j|_|�|j|��r<|j|jj}t|��}|�|��n|}|jr|�|j��|jS)z�
        Verify the geometry -- construct and return a GeometryCollection
        if necessary (for example if the model field is MultiPolygonField while
        the mapped shapefile only contains Polygons).
        )	r{rzrw�MULTI_TYPES�numr
�addrS�wkt)rZr�r��
multi_type�gs     r#r�zLayerMapping.verify_geom�s����>�T�^�+�+�!�^�D�N��?�?�4�>�;�7�7�	��)�$�.�*<�=�J��J�'�'�A�
�E�E�$�K�K�K�K��A�
�>�	(�
�K�K���'�'�'��u�r"c�(�|j���}	|j�|j���|jj���j}t|j	|��S#t$r}td��|�d}~wwxYw)z,Return the coordinate transformation object.)�sridz?Could not translate between the data source and model geometry.N)rHr�r�rFr�rOr�r�rrQ�	Exceptionr)rZ�
SpatialRefSys�
target_srs�excs    r#rRzLayerMapping.coord_transform�s����,�<�<�>�>�
�		�&�.�4�4�T�Z�@�@�D�D�$�.�J]�D�^�^�b�J�"�$�/�:�>�>�>���	�	�	��Q����
�����	���s�AA2�2
B�<B�Bc�N�|jj}|�|j��S)zHReturn the GeometryField instance associated with the geographic column.)rJrsrtro)rZ�optss  r#rNzLayerMapping.geometry_field�s"���z����~�~�d�o�.�.�.r"c�N�|j|jvo|jjd|jzkS)z�
        Given the OGRGeomType for a geometry and its associated GeometryField,
        determine whether the geometry should be turned into a GeometryCollection.
        zMulti%s)r�r�rur�django)rZrwr�s   r#rzzLayerMapping.make_multi�s3��
�
��!1�1�O��%�.�)�i�>N�2N�N�	Pr"Fc�����������|��}�r�dust�t��sd�n��|ddf�������fd�	}	�j���|	��}	�jj}
|r�t|t��r�||
kr�|rt
d���d\}}}
t||
|��}t|��}t|��D]l\}}|dz|krt|d��}nt||��}	|	|||
��\}}
|}�C#t$r��d	�d
|�d����wxYwdS|	��dS)a�
        Save 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 successfully 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.
        Ti�rc	���|r�j|}n�j}|D�]5}|dz
}	��|��}d}�jr�	��|��}�jj��j��jdi|��}d}t|�j	��}	|	�t|�j	��}
n;|	j}
t|�j	��}|D]}|
�|���t|�j	|
j��n*#t$r�jdi|��}YnwxYw�jdi|��}	|��j���|dz
}�r��|rdnd�d|�d���n�#t$$rb}
�r8�s5��d	|jz����d
|z����s��d|�d|
�d
���Yd}
~
nEd}
~
wwxYw#t($r0}
�r��s!��d|j�d|
�d���Yd}
~
nd}
~
wwxYw�r#|�zdkr��d||fz����7||fS)Nr/FT)rF�Updated�Savedz: �
zOFailed to save the feature (id: %s) into the model with the keyword arguments:
z%s
zFailed to save z:
 z
Continuing
zIgnoring Feature ID z
 because: rz$Processed %d features, saved %d ...
r!)rDr�rVr�rJr�rFr��getattrror
�ogrr��setattrr�r�save�writer��fidr)�
feat_range�num_feat�	num_saved�
layer_iterr�r��	is_update�u_kwargs�m�
geom_valuer��newr��msg�progress�progress_intervalrZ�silent�stream�strict�verboses              �������r#�_savez LayerMapping.save.<locals>._saves:����
(�!�Z�
�3�
�
�!�Z�
�"�@
b�@
b���A�
��9b�!�0�0��6�6�F�!&�I��{�1�5�(,�'9�'9�&�'A�'A�H� H��
� 2� 8� 8��� D� D� H� T� T�8� T� T�A�(,�I�*1��D�O�)D�)D�J�)�1�'2�6�$�/�3J�'K�'K���'1�~��&1�&���2I�&J�&J��),�!0�!0�A�$(�H�H�Q�K�K�K�K�#�A�t����A�A�A�A��1�5�5�5� *��
� 4� 4�V� 4� 4�A�A�A�5����'�D�J�0�0��0�0��b����T�Z��0�0�0�!�Q��	�"�`�"�L�L�I�7Z�y�y�SZ�7Z�7Z�\]�\]�\]�)^�_�_�_���$�b�b�b�!�
b�#)�>� &���%J�LP�H�%U�!"�!"�!"�!'���V�f�_� =� =� =�!�!'�b�"�L�L�L�TZ�TZ�TZ�\_�\_�\_�)`�a�a�a����������b�����Y%�_�_�_��_��#�_�����t�x�x�x�Y\�Y\�Y\�%]�^�^�^����������_����t�b��+<� <�� A� A��L�L�!H�H�V_�K`�!`�a�a�a���h�&�&sD�G.�CD�D,�+D,�=AE?�?
G+�	AG&�&G+�.
H(�8&H#�#H(NzOThe `step` keyword may not be used in conjunction with the `fid_range` keyword.)rrrr/z(=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-z
Failed to save slice: r�)
rcrAr�rXrDr�r�ranger��	enumerater`r�r�)rZr�rb�stepr�r�r�r��
default_ranger��nfeat�begr�r��indices�n_i�i�end�
step_slicer�s``  ````           @r#r�zLayerMapping.save�s����������T�,�,�Y�7�7�
��	-��4���z�(�C�'@�'@��$(�!�!�$,�!�*�Q�!�J	'�J	'�J	'�J	'�J	'�J	'�J	'�J	'�J	'�J	'�J	'�J	'�X�%�1��.�.�u�5�5�E��
�#���	�J�t�S�)�)�	�d�U�l�l��
w�#�$u�v�v�v�'0�$�C��9��D�%��.�.�G��g�,�,�C�#�G�,�,�

�

���3��q�5�C�<�<�!&�s�D�!1�!1�J�J�!&�s�C���J��*/�%�
�H�i�*P�*P�'�H�i��C�C�� �����L�L�Y�Y�Y�PZ�PZ�PZ�![�\�\�\������

�

� 
�E�G�G�G�G�Gs�D�'E)rNr;r<TNN)5rrr �__doc__rr�r�r�	AutoFieldr�BigAutoFieldr�SmallAutoField�BooleanFieldrrr��
FloatField�	DateFieldr
�
DateTimeFieldr�
EmailField�	TimeFieldrr�r��	SlugFieldr��URLField�	UUIDField�BigIntegerField�SmallIntegerField�PositiveBigIntegerField�PositiveIntegerField�PositiveSmallIntegerFieldrr\rcrKrPrUr�r�r�r�r�rRrNrz�sys�stdoutr�r!r"r#r.r.0s(������7�7�	
�;�;�|�$�$�	�;�;�(�)�)�	�;�;�~�&�&���J���#�[�[��%A�%A���O�$�$�(�+�+�6J�*K�*K���L�!�!�%�{�{�3D�'E�'E�
�K����*����\��	��z��	��j�'�9�=�	�
	��j�'�9�=��	��J��0�
�	��'��	��k��	��9��	��'��	��j�'�2��	��)��	��)��	��)��	���� 	��)�!�"	���W�i� @�#�$	� �:�w�	�"B��&��W�i�(H��#�j�'�9�%E��(�:�w�	�*J�+��K�045�+2�"5�48�EX�EX�EX�EX�P
�
�
�_1�_1�_1�B���$b�b�b����B	=�	=�	=�7�7�7�r���.���8���/�/�/�P�P�P�!�E���E�#�*�U�[�[�[�[�[�[r"r.)*r�r�decimalrrr��pathlibr�django.contrib.gis.db.modelsr�django.contrib.gis.gdalrrr	r
rr�django.contrib.gis.gdal.fieldr
rrrrrr�django.core.exceptionsrr�	django.dbrrrr�django.utils.encodingrr�rr&r(r*r,r.r!r"r#�<module>rs_�����
�
�
�H�H�H�H�H�H�H�H�������6�6�6�6�6�6�����������������������������������I�H�H�H�H�H�H�H�>�>�>�>�>�>�>�>�>�>�>�>�+�+�+�+�+�+�	�	�	�	�	�I�	�	�	�	�	�	�	�	�M�	�	�	�	�	�	�	�	�]�	�	�	�	�	�	�	�	�]�	�	�	�	�	�	�	�	�
�	�	�	�M	�M	�M	�M	�M	�M	�M	�M	�M	�M	r"

Youez - 2016 - github.com/yon3zu
LinuXploit