
    Mwg                     8    d dl Z  G d de      Z G d de      Zy)    Nc                   ,     e Zd ZdZ fdZ fdZ xZS )	Singletonz
    Singleton metaclass
    Based on Python Cookbook 3rd Edition Recipe 9.13
    Only one instance of a class can exist. Does not work with __slots__
    c                 2    t        |   |i | d | _        y N)super__init___Singleton__instanceselfargskw	__class__s      P/var/www/horilla/myenv/lib/python3.12/site-packages/openpyxl/compat/singleton.pyr   zSingleton.__init__   s    $%"%    c                 \    | j                   t        |   |i || _         | j                   S r   )r	   r   __call__r
   s      r   r   zSingleton.__call__   s-    ??"#g.;;DOr   __name__
__module____qualname____doc__r   r   __classcell__r   s   @r   r   r      s     r   r   c                   ,     e Zd ZdZ fdZ fdZ xZS )Cachedz
    Caching metaclass
    Child classes will only create new instances of themselves if
    one doesn't already exist. Does not work with __slots__
    c                 V    t        |   |i | t        j                         | _        y r   )r   r   weakrefWeakValueDictionary_Cached__cacher
   s      r   r   zCached.__init__   s%    $%"%224r   c                 x    || j                   v r| j                   |   S t        |   | }|| j                   |<   |S r   )r   r   r   )r   r   objr   s      r   r   zCached.__call__"   s@    4<<<<%%g% T
r   r   r   s   @r   r   r      s    5 r   r   )r   typer   r    r   r   <module>r$      s"     "T r   