
    kj                         d dl Z d dlmZ d dlmZ d dlmZmZmZ d dl	Z	d dl
Zd dlmZmZmZmZ d dlmZ d dlmZ  e j        e          Z G d d	          ZdS )
    N)Iterable)Path)AnyOptionalUnion)dataprogramscenetexture)BaseFilesystemFinder)ResourceDescriptionc                      e Zd ZU dZdZ	 g Zeee                  ed<   	 de	ddfdZ
eded          de	defd	            Zdefd
Zdeeeef                  dee         fdZdeeeef                  dee         fdZdeeeef                  dee         fdZdeeeef                  dee         fdZdeeeef                  dee         dee         fdZedej        fd            ZdS )
BaseLoaderz#Base loader class for all resourcesunknownfile_extensionsmetareturnNc                 p    || _         | j        't          d                    | j                            dS )zInitialize loader.

        Loaders take a ResourceDescription instance
        containing all the parameters needed to load and initialize
        this data.

        Args:
            meta (ResourceDescription): The resource to load
        NzLoader {} doesn't have a kind)r   kind
ValueErrorformat	__class__)selfr   s     W/home/agentuser/manim-venv/lib/python3.11/site-packages/moderngl_window/loaders/base.py__init__zBaseLoader.__init__&   s:     	9<CCDNSSTTT     clsc                     t          |j        |j        nd          }| j        D ]%}|j        dt	          |                   |k    r dS &dS )zCheck if the loader has a supported file extension.

        What extensions are supported can be defined in the
        :py:attr:`file_extensions` class attribute.
        N TF)r   pathr   suffixeslen)r   r   r    exts       r   supports_filezBaseLoader.supports_file4   s_     !6DIIB??& 	 	C}Zs3xxZ(C//tt 0 ur   c                     t                      )zLoads a resource.

        When creating a loader this is the only
        method that needs to be implemented.

        Returns:
            The loaded resource
        )NotImplementedErrorr   s    r   loadzBaseLoader.loadC   s     "###r   r    c                 P    |                      |t          j                              S )zFind resource using data finders.

        This is mainly a shortcut method to simplify the task.

        Args:
            path: Path to resource
        )_findr   get_findersr   r    s     r   	find_datazBaseLoader.find_dataN   s!     zz$ 0 2 2333r   c                 P    |                      |t          j                              S )zFind resource using program finders.

        This is mainly a shortcut method to simplify the task.

        Args:
            path: Path to resource
        )r*   r	   r+   r,   s     r   find_programzBaseLoader.find_programX   !     zz$ 3 5 5666r   c                 P    |                      |t          j                              S )zFind resource using texture finders.

        This is mainly a shortcut method to simplify the task.

        Args:
            path: Path to resource
        )r*   r   r+   r,   s     r   find_texturezBaseLoader.find_textureb   r0   r   c                 P    |                      |t          j                              S )zFind resource using scene finders.

        This is mainly a shortcut method to simplify the task.

        Args:
            path: Path to resource
        )r*   r
   r+   r,   s     r   
find_scenezBaseLoader.find_scenel   s!     zz$ 1 3 3444r   findersc                     |sdS t          |t                    rt          |          }|                                r|S |D ]}|                    |          }|r|c S t
                              d|           dS )zFind the first occurrance of this path in all finders.
        If the incoming path is an absolute path we assume this
        path exist and return it.

        Args:
            path (str): The path to find
        Nz No finder was able to locate: %s)
isinstancestrr   is_absolutefindloggerdebug)r   r    r5   finderresults        r   r*   zBaseLoader._findv   s      	4dC   	::D 	K 	 	F[[&&F  	7>>>tr   c                 (    t          j                    S )z"moderngl.Context: ModernGL context)mglwctxr'   s    r   rA   zBaseLoader.ctx   s     xzzr   )__name__
__module____qualname____doc__r   r   listr8   __annotations__r   r   classmethodtypeboolr$   r   r(   r   r   r   r-   r/   r2   r4   r   r   r*   propertymodernglContextrA    r   r   r   r      s        --D
 (*OT$s)_)))
U0 UT U U U U 4- 5H T    [	$c 	$ 	$ 	$ 	$4huS$Y'78 4Xd^ 4 4 4 47%T	*:!; 7 7 7 7 77%T	*:!; 7 7 7 7 75xc4i(89 5htn 5 5 5 5U39-.9ABV9W	$   4 X%    X  r   r   )loggingcollections.abcr   pathlibr   typingr   r   r   rL   moderngl_windowr@   moderngl_window.findersr   r	   r
   r   moderngl_window.finders.baser   moderngl_window.meta.baser   	getLoggerrB   r;   r   rN   r   r   <module>rX      s     $ $ $ $ $ $       ' ' ' ' ' ' ' ' ' '      A A A A A A A A A A A A = = = = = = 9 9 9 9 9 9		8	$	$C C C C C C C C C Cr   