o
    þÞh
  ã                   @   s`   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 G dd„ deƒZ
G dd	„ d	e
ƒZd
S )é    )Úapps)ÚGeometryField)ÚSitemap)Úmodels)Úreversec                   @   s@   e Zd ZdZdZddd„Zdd„ Zdd	d
„Zdd„ Zdd„ Z	dS )Ú
KMLSitemapz1
    A minimal hook to produce KML sitemaps.
    ÚkmlNc                 C   s   |   |¡| _d S ©N)Ú_build_kml_sourcesÚ	locations)Úselfr   © r   ú_/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/contrib/gis/sitemaps/kml.pyÚ__init__   s   zKMLSitemap.__init__c                 C   s˜   g }|du r
t  ¡ }|D ]=}t|tjjƒr/|jjD ]}t|tƒr-| 	|jj
|jj|jf¡ qqt|ttfƒrFt|ƒdkr@tdƒ‚| 	|¡ qtdƒ‚|S )zò
        Go through the given sources and return a 3-tuple of the application
        label, module name, and field name of every GeometryField encountered
        in the sources.

        If no sources are provided, then all models.
        Né   z?Must specify a 3-tuple of (app_label, module_name, field_name).z)KML Sources must be a model or a 3-tuple.)r   Ú
get_modelsÚ
isinstancer   ÚbaseÚ	ModelBaseÚ_metaÚfieldsr   ÚappendÚ	app_labelÚ
model_nameÚnameÚlistÚtupleÚlenÚ
ValueErrorÚ	TypeError)r   ÚsourcesÚkml_sourcesÚsourceÚfieldr   r   r   r
      s.   
ýÿ€þ	ÿzKMLSitemap._build_kml_sourcesé   c                 C   s*   t j| |||d�}|D ]}| j|d< q|S )z|
        This method is overridden so the appropriate `geo_format` attribute
        is placed on each URL element.
        )ÚpageÚsiteÚprotocolÚ
geo_format)r   Úget_urlsr(   )r   r%   r&   r'   ÚurlsÚurlr   r   r   r)   5   s   zKMLSitemap.get_urlsc                 C   s   | j S r	   )r   )r   r   r   r   Úitems?   s   zKMLSitemap.itemsc                 C   s&   t d| j |d |d |d dœd�S )Nz$django.contrib.gis.sitemaps.views.%sr   r$   é   )ÚlabelÚmodelÚ
field_name)Úkwargs)r   r(   )r   Úobjr   r   r   ÚlocationB   s   ýþzKMLSitemap.locationr	   )r$   NN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r(   r   r
   r)   r,   r3   r   r   r   r   r      s    

!
r   c                   @   s   e Zd ZdZdS )Ú
KMZSitemapÚkmzN)r4   r5   r6   r(   r   r   r   r   r8   M   s    r8   N)Údjango.appsr   Údjango.contrib.gis.db.modelsr   Údjango.contrib.sitemapsr   Ú	django.dbr   Údjango.urlsr   r   r8   r   r   r   r   Ú<module>   s    E