
0_c           @   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
 ru e Z	 n Xd   Z d   Z d   Z d	   Z d S(
   iN(   t   BytesIO(   t   settings(   t   HttpResponse(   t   loaderc         C   s]   t    } t j | d t j  # } | j d |  j t j   Wd QX| j d  | j	   S(   s1   Returns compressed KMZ from the given KML string.t   as   doc.kmlNi    (
   R    t   zipfilet   ZipFilet   ZIP_DEFLATEDt   writestrt   encodeR   t   DEFAULT_CHARSETt   seekt   read(   t   kmlt   kmzt   zf(    (    s>   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/shortcuts.pyt   compress_kml   s
    	"c          O   s   t  t j |  |   d d S(   s:   Renders the response as KML (using the correct MIME type).t   content_types$   application/vnd.google-earth.kml+xml(   R   R   t   render_to_string(   t   argst   kwargs(    (    s>   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/shortcuts.pyt   render_to_kml   s    c          O   s"   t  t t j |  |    d d S(   sZ   
    Compresses the KML content and returns as KMZ (using the correct
    MIME type).
    R   s    application/vnd.google-earth.kmz(   R   R   R   R   (   R   R   (    (    s>   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/shortcuts.pyt   render_to_kmz    s    c          O   s   t  t j |  |   d d S(   s8   Renders the response using the MIME type for plain text.R   s
   text/plain(   R   R   R   (   R   R   (    (    s>   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/shortcuts.pyt   render_to_text+   s    (   R   t   ioR    t   django.confR   t   django.httpR   t   django.templateR   t   numpyt   ImportErrort   FalseR   R   R   R   (    (    (    s>   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/gis/shortcuts.pyt   <module>   s   
				