U
    P’“e÷  ã                   @   sè   d Z dZddlmZmZmZ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ZddlZddlZd	eejd ƒgZed
krœeeeejd ƒdƒg7 Zeeejƒeedƒg7 Ze
jddd dejkfdd„Zdd„ Zdd„ ZdS )a  
Resources management
====================

Resource management can be a pain if you have multiple paths and projects.
Kivy offers 2 functions for searching for specific resources across a list
of paths.

Resource lookup
---------------

When Kivy looks for a resource e.g. an image or a kv file, it searches through
a predetermined set of folders. You can modify this folder list using the
:meth:`resource_add_path` and :meth:`resource_remove_path` functions.

Customizing Kivy
----------------

These functions can also be helpful if you want to replace standard Kivy
resources with your own. For example, if you wish to customize or re-style
Kivy, you can force your *style.kv* or *data/defaulttheme-0.png* files to be
used in preference to the defaults simply by adding the path to your preferred
alternatives via the :meth:`resource_add_path` method.

As almost all Kivy resources are looked up using the :meth:`resource_find`, so
you can use this approach to add fonts and keyboard layouts and to replace
images and icons.

)Úresource_findÚresource_add_pathÚresource_remove_pathé    )ÚjoinÚdirnameÚexistsÚabspath)Úkivy_data_dir)ÚCache)Úplatform)ÚLoggerNÚ.ZiosZYourAppz..úkv.resourcefindé<   )ÚtimeoutZKIVY_DOC_INCLUDEc                 C   s¬   | sdS d}|r$t  d| ¡}|r$|S | dd… dkr:| }nXt| ƒ}t|ƒrTt| ƒ}n,ttƒD ]"}tt|| ƒƒ}t|ƒr\|} q€q\|s’|  d¡r’| }|r¨|r¨t  d| |¡ |S )a.  Search for a resource in the list of paths.
    Use resource_add_path to add a custom path to the search.
    By default, results are cached for 60 seconds.
    This can be disabled using use_cache=False.

    .. versionchanged:: 2.1.0
        `use_cache` parameter added and made True by default.
    Nr   é   zatlas://zdata:)	r
   Úgetr   r   ÚreversedÚresource_pathsr   Ú
startswithÚappend)ÚfilenameZ	use_cacheZfound_filenameZabspath_filenameÚpath© r   ú2/tmp/pip-unpacked-wheel-xzebddm3/kivy/resources.pyr   2   s,    	
r   c                 C   s(   | t krdS t d|  ¡ t  | ¡ dS )z$Add a custom path to search in.
    NzResource: add <%s> in path list)r   r   Údebugr   ©r   r   r   r   r   U   s    r   c                 C   s(   | t krdS t d|  ¡ t  | ¡ dS )z7Remove a search path.

    .. versionadded:: 1.0.8
    Nz$Resource: remove <%s> from path list)r   r   r   Úremover   r   r   r   r   ^   s    r   )Ú__doc__Ú__all__Úos.pathr   r   r   r   Zkivyr	   Z
kivy.cacher
   Z
kivy.utilsr   Zkivy.loggerr   ÚsysÚosÚargvr   Ú__file__ÚregisterÚenvironr   r   r   r   r   r   r   Ú<module>   s"   #	