U
    ‰d  ã                   @   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
 d dlmZmZ G dd„ deƒZd	S )
é    )Úc_void_p)ÚGDALBase)ÚGDALException)Úds)Úraster)Úforce_bytesÚ	force_strc                
   @   s\   e Zd ZdZddddddddddœ	Zdd„ Zd	d
„ Zedd„ ƒZedd„ ƒZ	e
dd„ ƒZdS )ÚDriverzº
    Wrap a GDAL/OGR Data Source Driver.
    For more information, see the C API documentation:
    https://gdal.org/api/vector_c_api.html
    https://gdal.org/api/raster_c_api.html
    zESRI ShapefileZTIGERZGTiffZJPEG)	ZesriZshpÚshapeZtigerz
tiger/lineZtiffZtifZjpegZjpgc                 C   sÌ   t |tƒr^|  ¡  | ¡ | jkr0| j| ¡  }n|}ttfD ]}t| t	|ƒ¡ƒ}|r< q²q<nTt |t
ƒr’|  ¡  ttfD ]}| |¡}|rx q²qxn t |tƒr¢|}ntdt|ƒ ƒ‚|sÂtd| ƒ‚|| _dS )zT
        Initialize an GDAL/OGR driver on either a string or integer input.
        z/Unrecognized input type for GDAL/OGR Driver: %sz1Could not initialize GDAL/OGR Driver on input: %sN)Ú
isinstanceÚstrÚensure_registeredÚlowerÚ_aliasÚvcapiÚrcapir   Zget_driver_by_namer   ÚintZ
get_driverr   ÚtypeÚptr)ÚselfZdr_inputÚnameZifaceZdriver© r   úB/tmp/pip-unpacked-wheel-7vj2equ7/django/contrib/gis/gdal/driver.pyÚ__init__$   s2    




ÿÿzDriver.__init__c                 C   s   | j S )N)r   ©r   r   r   r   Ú__str__L   s    zDriver.__str__c                 C   s$   t  ¡ st  ¡  t ¡ s t ¡  dS )zB
        Attempt to register all the data source drivers.
        N)r   Úget_driver_countZregister_allr   ©Úclsr   r   r   r   O   s    zDriver.ensure_registeredc                 C   s   t  ¡ t ¡  S )zO
        Return the number of GDAL/OGR data source drivers registered.
        )r   r   r   r   r   r   r   Údriver_count[   s    zDriver.driver_countc                 C   s   t t | j¡ƒS )zA
        Return description/name string for this driver.
        )r   r   Zget_driver_descriptionr   r   r   r   r   r   b   s    zDriver.nameN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Úclassmethodr   r   Úpropertyr   r   r   r   r   r	   
   s&   õ(

r	   N)Úctypesr   Zdjango.contrib.gis.gdal.baser   Zdjango.contrib.gis.gdal.errorr   Z"django.contrib.gis.gdal.prototypesr   r   r   r   Zdjango.utils.encodingr   r   r	   r   r   r   r   Ú<module>   s   