
    [j                     2    d Z ddlZd Z G d d          ZdS )z8Thread-safe in-memory store for the Kubernetes informer.    Nc                    t          | t                    rF|                     d          pi }|                    d          pd}|                    d          pd}nzt          | dd          }|dS t	          |d          r't          |dd          pd}t          |dd          pd}n.|                    d          pd}|                    d          pd}|rd                    ||          S |S )zBuild a lookup key from object metadata.

    Supports both dict-based objects and generated model objects.
    Returns namespace/name for namespaced objects, just name otherwise.
    metadata	namespace nameNz{}/{})
isinstancedictgetgetattrhasattrformat)objmetansr   s       V/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/kubernetes/informer/cache.py_meta_namespace_keyr      s    #t *wwz""(bXXk""(bxx%2sJ--<24%% 	*{D117RB4..4"DD+&&,"B88F##)rD	 (~~b$'''K    c                   D    e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 ZdS )ObjectCachezThread-safe in-memory mapping of Kubernetes objects.

    The SharedInformer keeps this store synchronised with the API server.
    Consumers can call list() and get_by_key() from any thread safely.
    Nc                 d    ||nt           | _        i | _        t          j                    | _        d S N)r   	_key_func_objects	threadingRLock_rlock)selfkey_funcs     r   __init__zObjectCache.__init__4   s-    %-%9?Ro''r   c                     |                      |          }| j        5  || j        |<   d d d            d S # 1 swxY w Y   d S r   )r   r   r   r   r   keys      r   _putzObjectCache._put;   s    nnS!![ 	% 	%!$DM#	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   599c                     |                      |          }| j        5  | j                            |d            d d d            d S # 1 swxY w Y   d S r   )r   r   r   popr!   s      r   _removezObjectCache._remove@   s    nnS!![ 	) 	)Mc4(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   AA
A
c                 r      fd|D             } j         5  | _        d d d            d S # 1 swxY w Y   d S )Nc                 <    i | ]}                     |          |S  )r   ).0or   s     r   
<dictcomp>z,ObjectCache._replace_all.<locals>.<dictcomp>F   s'    999A4>>!$$a999r   )r   r   )r   objectsrebuilts   `  r   _replace_allzObjectCache._replace_allE   s    9999999[ 	$ 	$#DM	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s   ,00c                     | j         5  t          | j                                                  cddd           S # 1 swxY w Y   dS )z-Return a snapshot list of all cached objects.N)r   listr   valuesr   s    r   r1   zObjectCache.listL   s    [ 	0 	0,,..//	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0   &;??c                     | j         5  t          | j                                                  cddd           S # 1 swxY w Y   dS )z)Return a snapshot list of all cache keys.N)r   r1   r   keysr3   s    r   	list_keyszObjectCache.list_keysQ   s    [ 	. 	.**,,--	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.r4   c                 V    |                      |          }|                     |          S )z9Look up the cached copy of obj. Returns None when absent.)r   
get_by_keyr!   s      r   r
   zObjectCache.getV   s%    nnS!!s###r   c                 x    | j         5  | j                            |          cddd           S # 1 swxY w Y   dS )z3Look up an object by key. Returns None when absent.N)r   r   r
   )r   r"   s     r   r9   zObjectCache.get_by_key[   s    [ 	* 	*=$$S))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   /33r   )__name__
__module____qualname____doc__r   r#   r&   r/   r1   r7   r
   r9   r)   r   r   r   r   -   s         ( ( ( (% % %
) ) )
$ $ $0 0 0
. . .
$ $ $
* * * * *r   r   )r>   r   r   r   r)   r   r   <module>r?      sZ    ? >      21* 1* 1* 1* 1* 1* 1* 1* 1* 1*r   