
    ZhZ                        d Z ddlZddlZddlmZ ddlmZ ej                  j                  d      Z	ej                  j                  de	      j                  ej                        Z G d de      Zd	 Zed
        Zd Zy)z
Image location support
    N)List)cachez
~/.iconifyICONIFY_PATHc                       e Zd Zy)IconNotFoundErrorN)__name__
__module____qualname__     [/mounts/lovelace/software/anaconda3/envs/py312/lib/python3.12/site-packages/iconify/path.pyr   r      s    r   r   c                 .    t         j                  |        y)z
    Add the provided path to the list of directories that iconify will use
    when looking for svg files.

    Parameters
    ----------
    directoryLocation : str
    N)
_ICON_PATHappend)directoryLocations    r   addIconDirectoryr      s     '(r   c                    t         j                  j                  |       r;t         j                  j                  |       st	        dj                  |             | S | j                  dt         j                        } t        D ]H  }t         j                  j                  || dz         }t         j                  j                  |      sF|c S  t	        dj                  |             )a	  
    Use the provided string to find an svg file on the iconify path.

    Any `:`'s in the provided string will be replaced with the current
    platform's directory separator.

    Parameters
    ----------
    iconPath : str

    Returns
    -------
    str
    zUnable to locate icon file: {}:z.svgz<Unable to find an icon on the ICONIFY_PATH that matches '{}')
ospathisabsisfiler   formatreplacesepr   join)iconPathdir_absIconPaths      r   findIconr        s    " 
ww}}Xww~~h'#077A  ##C0 	#D'',,tX->?Kww~~k*""	#
  JF8
 	
r   c                     g } t         D ]  }t        j                  |      D ]  \  }}}t        j                  |d      D ]  }t        j
                  j                  ||      }|j                  |d      }t        j
                  j                  |      \  }}|j                  t        j                        j                  t        j                  d      }| j                  t        |                | S )z\
    Return all icons found on the iconify path.

    Returns
    -------
    List[str]
    z*.svg r   )r   r   walkfnmatchfilterr   r   r   splitextlstripr   r   str)matchesr   rootdirnames	filenamesfilenamefilePath_s           r   	listIconsr0   D   s     G .)+ 	.%D(I#NN9g> .77<<h7#++D"5 gg..x8!#??2662::2663Gs8}-.	.. Nr   )__doc__r$   r   typingr   
kids.cacher   r   
expanduser	_USER_DIRenvirongetsplitpathsepr   	Exceptionr   r   r    r0   r   r   r   <module>r;      sz     	  GG|,	ZZ^^NI6<<RZZH
		 	
)  
  
Fr   