
v^                 @   s   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z d  d l m Z y d  d l	 Z	 Wn e
 k
 rv d Z	 Yn Xd d   Z d	 d
   Z d d   Z d S)    N)BytesIO)settings)HttpResponse)loaderFc             C   s^   t    } t j | d t j  # } | j d |  j t j   Wd QRX| j d  | j	   S)z0Return compressed KMZ from the given KML string.azdoc.kmlNr   )
r   zipfileZipFileZIP_DEFLATEDwritestrencoder   DEFAULT_CHARSETseekread)ZkmlZkmzzf r   >/tmp/pip-build-8lau8j11/django/django/contrib/gis/shortcuts.pycompress_kml   s
    	#r   c              O   s   t  t j |  |   d d S)z9Render the response as KML (using the correct MIME type).content_typez$application/vnd.google-earth.kml+xml)r   r   render_to_string)argskwargsr   r   r   render_to_kml   s    r   c              O   s"   t  t t j |  |    d d S)zW
    Compress the KML content and return as KMZ (using the correct
    MIME type).
    r   z application/vnd.google-earth.kmz)r   r   r   r   )r   r   r   r   r   render_to_kmz    s    r   )r   ior   Zdjango.confr   Zdjango.httpr   Zdjango.templater   ZnumpyImportErrorr   r   r   r   r   r   r   <module>   s   	