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.
    ZkmlNc                 C   s   |  || _d S N)_build_kml_sources	locations)selfr
    r   /home/ubuntu/experiments/live_experiments/Pythonexperiments/Otree/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   Z
get_models
isinstancer   baseZ	ModelBase_metafieldsr   appendZ	app_labelZ
model_namenamelisttuplelen
ValueError	TypeError)r   sourcesZ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&   r-   r   r   r   r   r      s    

!
r   c                   @   s   e Zd ZdZdS )
KMZSitemapZkmzN)r.   r/   r0   r"   r   r   r   r   r2   M   s    r2   N)Zdjango.appsr   Zdjango.contrib.gis.db.modelsr   Zdjango.contrib.sitemapsr   Z	django.dbr   Zdjango.urlsr   r   r2   r   r   r   r   <module>   s    E