o
    ¤pf2  ã                   @  sj   d dl mZ d dlmZ d dlZd dlmZ d dlmZ d dl	m
Z
 e
r*d dlmZ eG dd	„ d	ƒƒZdS )
é    )Úannotations)Ú	dataclassN)ÚConfig)ÚTile)ÚTYPE_CHECKING)ÚStoragec                   @  s~   e Zd ZU dZded< ded< ded< ded< ded	< ed!dd„ƒZed"dd„ƒZd#dd„Zd#dd„Z	d$dd„Z
d%dd„Zd S )&ÚTilesetz”A set of tiles in storage

    A tileset must always have the associated DB entries with tilejson/etc
    TODO: How to handle populating the DB
    r   ÚstorageÚstrÚidÚintÚminzoomÚmaxzoomÚtilejsonÚconfigr   c                 C  s   | ||j |j|j| d¡ƒS )z*Create a tileset from a Storage and ConfigÚREPLACED_BY_SERVER)r   r   r   r   )Úclsr	   r   © r   úI/home/ertert/spirit/venv/lib/python3.10/site-packages/tilekiln/tileset.pyÚfrom_config   s   ÿzTileset.from_configÚreturnc                 C  s0   |  |¡}|  |¡}| |d¡}| |||||ƒS )zj
        Create a tileset from a Storage and id

        This pulls the metadata from the storage
        r   )Úget_minzoomÚget_tilejson)r   r	   r   r   r   r   r   r   r   Úfrom_id!   s   

zTileset.from_idÚNonec                 C  s   | j  | j| j| j| j¡ d S ©N)r	   Úcreate_tilesetr   r   r   r   ©Úselfr   r   r   Úprepare_storage-   s   ÿzTileset.prepare_storagec                 C  s   | j  | j| j| j| j¡ dS )zSets the metadata in storageN)r	   Úset_metadatar   r   r   r   r   r   r   r   Úupdate_storage_metadata1   s   ÿzTileset.update_storage_metadataÚtiler   ú-tuple[bytes | None, datetime.datetime | None]c                 C  s   | j  | j|¡S r   )r	   Úget_tiler   )r   r"   r   r   r   r$   6   s   zTileset.get_tileÚdataÚbytesúdatetime.datetime | Nonec                 C  s   | j  | j||¡S r   )r	   Ú	save_tiler   )r   r"   r%   r   r   r   r(   9   s   zTileset.save_tileN)r	   r   r   r   )r	   r   r   r
   r   r   )r   r   )r"   r   r   r#   )r"   r   r%   r&   r   r'   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__Úclassmethodr   r   r   r!   r$   r(   r   r   r   r   r      s   
 


r   )Ú
__future__r   Údataclassesr   ÚdatetimeÚtilekiln.configr   Útilekiln.tiler   Útypingr   Útilekiln.storager   r   r   r   r   r   Ú<module>   s    